当属性不存在时,选择节点的Xpath查询?

Ant*_*ine 26 xpath attributes

我想选择不存在特定属性的节点.我尝试过Not()函数,但它不起作用.有办法吗?

示例:以下Xpath查询:

group/msg[not(@owner)]
Run Code Online (Sandbox Code Playgroud)

应该检索第一个节点而不是第二个节点.但是,SketchPath(测试Xpath查询的工具)和我的C#代码都认为2个节点都可以.

<group>
    <msg id="EVENTDATA_CCFLOADED_XMLCONTEXT"  numericId="14026"  translate="False"  topicId="302"  status="translated" >
        <text>Context</text>
        <comment></comment>
    </msg>
    <msg id="EVENTDATA_CCFLOADED_XMLCONTEXT_HELP"  numericId="14027"  translate="False"  topicId="302"  status="translated"  owner="EVENTDATA_CCFLOADED_XMLCONTEXT" >
        <text>Provides the new data displayed in the Object.</text>
        <comment></comment>
    </msg>
</group>
Run Code Online (Sandbox Code Playgroud)

事实上,Not()函数正常工作,只是我有其他条件和圆括号未正确设置.errare humanum est.

Jon*_*röm 17

在一些旧的,不是非常标准的XPath引擎中,我必须string-length(@attr)=0出于同样的原因使用它.