我想选择不存在特定属性的节点。我尝试了Not()函数,但它不起作用。有没有办法呢?当属性不存在时Xpath查询选择节点?
示例: 以下XPath查询:
group/msg[not(@owner)]
应检索的第一个节点,但不是第二之一。但是,SketchPath(测试Xpath查询的工具)和我的C#代码都认为这两个节点都可以。
<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>
其实不是()函数正常工作,它只是我有其他条件和括号设定不正确。 errare humanum est。
如果是这样,请关闭这个问题 - 这对其他人来说是误导和耗时的。 – 2008-12-12 16:40:34
如果你不介意,我把问题解决为“不再相关”。 – PhiLho 2008-12-12 20:20:04