Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/cassandra/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# xpath查询以选择属性不存在的元素_C#_Xpath_Xpathnavigator - Fatal编程技术网

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

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> **** 我想

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>

****
我想更新属性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(@*)]
重复-重复-