使用功能添加名称空间后:
var select = useNamespaces({ns1: "http://pippo.com/schema"})
我使用以下语句:
var Objects = select("//ns1:References/ns1:Reference[@ReferenceType="+typeofref+"]/text()="+id.toString(), ns);
我想要的输出是具有ReferenceType = typeofref和text()= id的所有引用
我得到的输出是:True
似乎找到了东西,但是它只是说有元素,但没有检索到它。有人知道为什么吗?
xm文件是这个:
您的XPath以=
+ 某字符串]结尾,因此只会返回true
或false
。
更改
"//ns1:References/ns1:Reference[@ReferenceType="+typeofref+"]/text()="+id.toString()
to
"//ns1:References/ns1:Reference[@ReferenceType="+typeofref+" and .="+id.toString()+"]"
为了选择
ns1:References/ns1:Reference
属性的typeofref
值和@ReferenceType
的字符串值的所有id.toString()
元素。