xpath 查询以选择属性不存在的元素

sun*_*der 0 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>
Run Code Online (Sandbox Code Playgroud)

我想更新属性 att 不存在的元素。

谢谢

Jon*_*eet 5

您可以使用[@att]来测试属性是否存在,因此您只需要:

//elem[not(@att)]
Run Code Online (Sandbox Code Playgroud)

...测试它的缺失

使用 xpathtester 测试