如何在java中删除Jtidy中的警告 [英] how to remove the warnings in Jtidy in java

查看:109
本文介绍了如何在java中删除Jtidy中的警告的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在java中使用Jtidy解析器。

I am using Jtidy parser in java.

URL url = new URL("www.yahoo.com"); 
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
InputStream in = conn.getInputStream(); 
doc = new Tidy().parseDOM(in, null);

当我运行它时,doc = new Tidy()。parseDOM(in,null);
我收到如下警告:

when I run this, "doc = new Tidy().parseDOM(in, null);" I am getting some warnings as follows:

Tidy (vers 4th August 2000) Parsing "InputStream"
line 140 column 5 - Warning: <table> lacks "summary" attribute

InputStream: Doctype given is "-//W3C//DTD XHTML 1.0 Strict//EN"
InputStream: Document content looks like HTML 4.01 Transitional

1 warnings/errors were found!

这些警告会自动显示在控制台上。但我不希望这些
警告在运行后显示在我的控制台上

These warnings are getting displayed automatically on console. But I don't want these warnings to be displayed on my console after running

doc = new Tidy().parseDOM(in, null);

请帮助我,如何执行此操作,如何从控制台删除这些警告。

Please help me,how to do this,how to remove these warnings from console.

推荐答案

查看文档我发现了一些可能做你想做的方法。

Looking at the Documentation I found a few methods which may do what you want.

setShowErrors setQuiet setErrout 。您可能需要尝试以下操作:

There is setShowErrors, setQuiet and setErrout. You may want to try the following:

Tidy tidy = new Tidy();
tidy.setShowErrors(0);
tidy.setQuiet(true);
tidy.setErrout(null);
doc = tidy.parseDOM(in, null);

其中一个已经足够了,这些都是我找到的所有选项。请注意,这只是隐藏消息,而不是对它们做任何事情。即使生成了错误,也有 setForceOutput 来获取输出。

One of them may be enough already, these were all the options I found. Note that this will simply hide the messages, not do anything about them. There is also setForceOutput to get the output, even if errors were generated.

这篇关于如何在java中删除Jtidy中的警告的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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