How can I get the error/warning messages out of the parsed HTML using JTidy?

Posted by chetu on Stack Overflow See other posts from Stack Overflow or by chetu
Published on 2010-03-16T16:03:48Z Indexed on 2010/03/24 14:43 UTC
Read the original article Hit count: 486

Filed under:
|
|
|

I am able to parse the HTML but I want to extract the warning messages from the parsed HTML and show them to the user.

Here is my code:

Tidy tidy = new Tidy();
StringBuffer StringBuffer1 = new StringBuffer("<b>Hello<u><b>I am tsting another one.....<i>another.....");
InputStream in = new ByteArrayInputStream(StringBuffer1.toString().getBytes("UTF-8"));
Writer stringWriter = new StringWriter();
    tidy.setPrintBodyOnly(true);
    tidy.setQuiet(true);
    tidy.setShowWarnings(true);
    tidy.setTidyMark(false);
    tidy.setXHTML(true);
    tidy.setXmlTags(false);
    Node parsedNode = tidy.parse(in, stringWriter);
    System.out.print(stringWriter.toString());

© Stack Overflow or respective owner

Related posts about tidy

Related posts about html