【发布时间】:2025-12-01 00:05:02
【问题描述】:
我将 XOM 与以下示例数据一起使用:
Element root = cleanDoc.getRootElement();
//find all the bold elements, as those mark institution and clinic.
Nodes nodes = root.query("//*");
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:html="http://www.w3.org/1999/xhtml">
<head>
<title>Patient Information</title>
</head>
</html>
以下元素返回许多元素(来自真实数据):
//*
但是像
//head
什么都不返回。如果我遍历根的孩子,数字似乎匹配,如果我打印元素名称,一切似乎都正确。
我正在获取 HTML,用 tagoup 解析它,然后从生成的字符串构建一个 XOM 文档。这其中的哪一部分会出现如此可怕的错误?我觉得这里发生了一些奇怪的编码问题,但我只是没有看到它。 Java 字符串就是字符串,对吧?
【问题讨论】:
标签: java xpath xml-namespaces xom tag-soup