2
我能夠解析HTML,但我想從解析的HTML中提取警告消息並將其顯示給用戶。如何使用JTidy從解析的HTML中獲取錯誤/警告消息?
這裏是我的代碼:
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());