【问题标题】:XML - SelectNodes - How to get nodes with attribute with some value (MFC)XML - SelectNodes - 如何获取具有某些值的属性的节点(MFC)
【发布时间】:2013-02-12 06:53:26
【问题描述】:

我在 MFC 工作

我想从 XML 获取所有节点,属性有一些值但值不应该为空,如果没有属性不应该选择节点

<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?

【问题讨论】:

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


    【解决方案1】:

    给定如下结构:

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

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

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

    【讨论】:

      猜你喜欢
      • 2021-10-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-02-08
      • 2013-04-20
      • 1970-01-01
      相关资源
      最近更新 更多