【发布时间】:2010-10-08 09:21:40
【问题描述】:
我有这个带有命名空间的 XML 文档,我想使用 XPath 提取一些节点。
这是文件:
<ArrayOfAnyType xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://tempuri.org/">
<anyType xsi:type="Document">
<Id>5</Id>
<Title>T1</Title>
</anyType>
<anyType xsi:type="Document">
<Id>15</Id>
<Title>T15</Title>
</anyType>
</ArrayOfAnyType>
如果我想提取所有带有 xsi:type="Document" 的“anyType”元素,XPath 表达式会是什么?
我试过这个:
//anyType[@xsi:type="Document"]
它不起作用:
【问题讨论】:
-
您使用的是哪个版本的 xpath? xpath 版本处理命名空间的方式不同?
-
看起来我必须说:'//xmlns:anyType[@xsi:type="Document"]' 才能工作
标签: xml xpath namespaces