我正在尝试使用jTidy从(现实世界)HTML.But jTidy不解析自定义标签中提取数据。
<html>
<body>
<myCustomTag>some text</myCustomTag>
<anotherCustom>more text</anotherCustom>
</body>
</html>我不能在自定义标记之间获取文本,我必须使用jTidy,因为我将使用xpath。
我尝试过HTMLCleaner,但它不支持完整的xpath函数。
发布于 2013-09-09 16:14:45
还可以使用Java properties对象设置属性,例如:
import java.util.Properties;
Properties oProps = new Properties();
oProps.setProperty("new-blocklevel-tags", "header hgroup article footer nav");
Tidy tidy = new Tidy();
tidy.setConfigurationFromProps(oProps);这将使您不必创建和加载配置文件。
发布于 2012-03-17 04:41:23
查看http://tidy.sourceforge.net/docs/quickref.html#new-blocklevel-tags
最简单的方法是创建一个文件,我将我的文件命名为jTidyTags,并调用:
Tidy tidy = new Tidy();
tidy.setConfigurationFromFile("jTidyTags");在那之后,它会抛出一条警告,说它不符合W3C,但谁在乎呢。这将允许您解析该文件。
为您提供的jTidyTags示例如下:
new-blocklevel-tags: myCustomTag anotherCustom希望这能有所帮助!
https://stackoverflow.com/questions/8976637
复制相似问题