C ++ Boost-如何获取具有特定属性的节点?

时间:2018-08-08 15:16:33

标签: c++ xml tree

假设我有这个XML文件:

    <root>
        <firstnode version="1.0">
            <A>
                <description>This is the A property</description>
                <type>Integer</type>
            </A>
            <B>
                <description>This is the B property</description>
                <type>String</type>
            </B>
            <C>
                <description>This is the C property</description>
                <type>Integer</type>
            </C>
        </firstnode>
        <firstnode version="2.0">
            <B>
                <description>This is the B property</description>
                <type>Double</type>
            </B>
        </firstnode >
        <firstnode version="5.0">
            <C>
                <description>This is the C property</description>
                <type>Float</type>
            </C>
        </firstnode >
    </root>

在这种特殊情况下,如何使用boost get 函数提取叶节点,其中每个以根为父节点的节点都具有相同的名称( firstnode ),但属性不同?

换句话说,我正在寻找一种功能类似的功能:

  string descB_Ver2_0 =  ptree.get<string>("root.firstnode.<xlmattr>.version.?.B.description");

谢谢。

0 个答案:

没有答案