使用jericho api
,我可以验证给定的 html 标签<input type="test" .....>
吗?我无法在 jericho 中找到可以这样做的 api。有没有一种方法可以让我jericho
只使用它?我不想整理或清理 html 标签。我只是想检查它的有效性。
问问题
434 次
1 回答
0
jericho api
will log all the validations telling you all your flaws and gaps in the constructed html you are validating. It does its own version of tag tidying but also logs that information of it's version of the logger
.
Let's try to print what jericho thinks about your html
tag:
PrintWriter writer = new PrintWriter(System.out);
WriterLogger myLogger = new WriterLogger(writer);
myLogger.setInfoEnabled(true);
Source source = new Source("<input type=\"test\" .....>");
source.setLogger(myLogger);
try {
source.getSourceFormatter().writeTo(writer);
} catch (Exception e) {
e.printStackTrace();
}
Output which I get is:
ERROR: StartTag input at (r1,c1,p0) contains attribute name with invalid first character at position (r1,c20,p19)
<input type="test" .....>
This log entry looks to be parseable and can be used in more than one way.
于 2014-01-23T12:06:56.383 回答