2
我加載一個boost :: property_tree :: ptree中從一個XML文件,這看起來有點像這樣:如何遍歷boost :: propertytree中的子節點,如果這些子節點本身?
<bla>
<foo>
<element id="1" type="..." path="..."/>
<element id="2" type="..." path="..."/>
<element id="3" type="..." path="..."/>
<otherelement/>
</foo>
</bla>
我加載到屬性樹與read_xml。現在我想構建一個包含結構的向量,類似於element
-tags。我能做到以下幾點:
BOOST_FOREACH(ptree::value_type& node, tree.get_child("bla.foo"))
{
if (node.first == "element")
{
...
}
}
到目前爲止,這是很好的,但我有問題獲得元素中的數據。 node.second
應該包含,但我如何正確訪問它? node.second.get("xmlattr.type")
不起作用。