如何使用JTidy从解析的HTML中获取错误/警告消息? [英] How can I get the error/warning messages out of the parsed HTML using JTidy?

查看:128
本文介绍了如何使用JTidy从解析的HTML中获取错误/警告消息?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我能够解析HTML,但我想从解析的HTML中提取警告消息并将其显示给用户。

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


推荐答案

以下是 doc

这篇关于如何使用JTidy从解析的HTML中获取错误/警告消息?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆