JTidy Node.findBody() — 如何使用? [英] JTidy Node.findBody() — How to use?
问题描述
我正在尝试使用 JTidy 进行 XHTML DOM 解析,这似乎是一项违反直觉的任务.特别是,有一种解析 HTML 的方法:
Node Tidy.parse(Reader, Writer)
并获得 <body/>那个节点,我想,我应该使用
Node Node.findBody(TagTable)
我应该从哪里获得该 TagTable 的实例?(构造函数受到保护,我还没有找到生产它的工厂.)
我使用 JTidy 8.0-SNAPSHOT.
我发现有很多更简单的方法来提取正文:
<前>整洁 = 新的整洁();tidy.setXHTML(true);tidy.setPrintBodyOnly(true);然后在 Reader-Writer 对上使用 tidy.
应该很简单.
I'm trying to do XHTML DOM parsing with JTidy, and it seems to be rather counterintuitive task. In particular, there's a method to parse HTML:
Node Tidy.parse(Reader, Writer)
And to get the <body /> of that Node, I assume, I should use
Node Node.findBody(TagTable)
Where should I get an instance of that TagTable? (Constructor is protected, and I haven't found a factory to produce it.)
I use JTidy 8.0-SNAPSHOT.
I found there's much simpler method to extract the body:
tidy = new Tidy(); tidy.setXHTML(true); tidy.setPrintBodyOnly(true);
And then use tidy on the Reader-Writer pair.
Simple as it should be.
这篇关于JTidy Node.findBody() — 如何使用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!