views:

31

answers:

1

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());
A: 

I noticed it in the jTidy documentation that starting from release r8 jTidy privdes TidyMessageListener interface you can implement to be notified for warning and errors in your html code.

Here is the doc

chetu