XML - SelectNodes - 如何获取具有某个值的属性的节点(MFC)

时间:2013-02-12 06:53:27

标签: c++ xml visual-c++ mfc msxml

我在MFC工作

我想从XML获取所有节点,其中属性具有某些值,但值不应为null,如果没有属性,则不应选择节点

<node att="sss"> - should be selected
<node att="sd342ss"> - should be selected
<node att=""> - empty value should not be selected
<node > - not having attribute should not be selected

如何为此创建XPATH?

1 个答案:

答案 0 :(得分:1)

给出如下结构:

<root>
    <node att="sss" />
    <node att="sd342ss" /> 
    <node att="" />
    <node />
</root>

您的XPath只选择具有属性且属性值不为空的节点,如下所示:

"//node[@att and string-length(@att) > 0]"