0

can anybody give sample program for converting xhtml doc to xml using jtidy in java.

or otherwise post the tutorial link for using jtidy

KB22
  • 6,899
  • 9
  • 43
  • 52

3 Answers3

2

You might find these examples interesting.

KB22
  • 6,899
  • 9
  • 43
  • 52
2

A XHTML document is already a XML document, so basically you don't have to do anything.

Kico Lobo
  • 4,374
  • 4
  • 35
  • 48
1

You can use a simple code for this;

Tidy tidy = new Tidy();
tidy.setMakeClean(true);
tidy.setXmlOut( true);

URL url = new URL("url_string_here");

FileOutputStream fileOutputStream = new FileOutputStream("outXHTML.xml");   

Document doc = tidy.parseDOM( url.openStream(), fileOutputStream);

Hope this helps.

jaxvy
  • 5,040
  • 1
  • 21
  • 22