JTidy Node.findBody() — 如何使用?
我正在尝试使用 JTidy 进行 XHTML DOM 解析,这似乎是相当违反直觉的任务。 特别是,有一个解析 HTML 的方法:
Node Tidy.parse(Reader, Writer)
并获取 > 我想,我应该使用该节点的位置,
Node Node.findBody(TagTable)
我应该在哪里获取该 TagTable 的实例? (构造函数是受保护的,我还没有找到工厂来生产它。)
我使用JTidy 8.0-SNAPSHOT。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我发现有更更简单的方法来提取正文:
然后在读写器对上使用 tidy 。
应该如此简单。
I found there's much simpler method to extract the body:
And then use tidy on the Reader-Writer pair.
Simple as it should be.
您可以改用
parseDOM
方法,这会给您一个org.w3c.dom.Document
返回:You could use the
parseDOM
method instead, which would give you aorg.w3c.dom.Document
back: