C# xpath查询以选择属性不存在的元素
xpath查询应该是什么来选择属性att不存在的元素C# xpath查询以选择属性不存在的元素,c#,xpath,xpathnavigator,C#,Xpath,Xpathnavigator,xpath查询应该是什么来选择属性att不存在的元素 <root> <elem att='the value' /> <elem att='the value' /> <elem att='the value' /> **<elem />** <elem att='the value' /> <elem att='the value' /> </root> **** 我想
<root>
<elem att='the value' />
<elem att='the value' />
<elem att='the value' />
**<elem />**
<elem att='the value' />
<elem att='the value' />
</root>
****
我想更新属性att不存在的元素
<root>
<elem att='the value' />
<elem att='the value' />
<elem att='the value' />
**<elem />**
<elem att='the value' />
<elem att='the value' />
</root>
谢谢您可以使用
[@att]
测试属性的存在性,因此您只需要:
//elem[not(@att)]
。。。测试是否缺少它
()您可以使用
[@att]
测试属性的存在性,因此您只需要:
//elem[not(@att)]
。。。测试是否缺少它
()此外,您还可以使用
@*
(属性::*)表示任何属性
对于任何属性示例:
//elem[@*]
//elem[not(@*)]
没有任何属性示例:
//elem[@*]
//elem[not(@*)]
此外,您还可以使用
@*
(属性::*)表示任何属性
对于任何属性示例:
//elem[@*]
//elem[not(@*)]
没有任何属性示例:
//elem[@*]
//elem[not(@*)]
重复-重复-