如何在Java中使用Jericho查找自定义开始标记?
正如标题所说,我正在尝试以如何在Java中使用Jericho查找自定义开始标记?,java,jericho-html-parser,Java,Jericho Html Parser,正如标题所说,我正在尝试以 我该如何对待耶利哥 编辑: 我已创建以下自定义StartTagType: PrimoResultStartTagType primoSTT = new PrimoResultStartTagType("search", "<sear:DOC", ">", EndTagType.NORMAL, false, true, true); 但是,当我执行source.getAllegements(…)时,我没有得到匹配项。也许这会有帮助: html示例: <
我该如何对待耶利哥
编辑:
我已创建以下自定义StartTagType:
PrimoResultStartTagType primoSTT = new PrimoResultStartTagType("search", "<sear:DOC", ">", EndTagType.NORMAL, false, true, true);
但是,当我执行source.getAllegements(…)
时,我没有得到匹配项。也许这会有帮助:
html示例:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" "http://www.w3.org/TR/html4/frameset.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>StartTagType (Jericho HTML Parser 3.1)</title>
</head>
<body>
<span>simple tag</span>
<test:name>custom tag</test:name>
</body>
</html>
似乎我的起始定界符不起作用,即使我输入了“下面建议的解决方案怎么样?”?
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" "http://www.w3.org/TR/html4/frameset.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>StartTagType (Jericho HTML Parser 3.1)</title>
</head>
<body>
<span>simple tag</span>
<test:name>custom tag</test:name>
</body>
</html>
public class Main {
public static void main(String[] args)
throws IOException {
URL url = Main.class.getClassLoader().getResource("test.html");
Source source = new Source(url);
List<Element> elementList = source.getAllElements("test:name");
for (Element element : elementList) {
System.out.println("Custom tag content: " + element.getContent().toString());
}
}
Custom tag content: custom tag