Created
May 22, 2012 20:47
-
-
Save mcenirm/2771534 to your computer and use it in GitHub Desktop.
Convert HTML to XML using TagSoup
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
XMLReader tagSoupReader = new org.ccil.cowan.tagsoup.Parser(); | |
Transformer identityTransformer = TransformerFactory.newInstance().newTransformer(); | |
Reader sourceReader = new FileReader(sourceFile); | |
InputSource sourceInputSource = new InputSource(sourceReader); | |
Source xmlSource = new SAXSource(tagSoupReader, sourceInputSource); | |
Result outputTarget = new StreamResult(outputFile); | |
identityTransformer.transform(xmlSource, outputTarget); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment