我使用XOM與下面的示例數據:XPath表達式返回沒有爲//元素,但// *返回計數
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,使用tagsoup解析它,然後從生成的字符串構建一個XOM文檔。這其中的哪一部分可能會出現如此可怕的錯誤?我覺得這裏有一些奇怪的編碼問題,但我只是沒有看到它。 Java字符串是字符串,對不對?
我想你想要什麼(//頭帶ns聲明)可以使用vtd-xml – 2010-02-24 06:07:09