samedi 18 juin 2016

Select only nodes of Boost ptree


Considering the following XML-file:

<debug>
    <modules group="0">
        <module>Finance</module>
        <module>Admin</module>
        <module>HR</module>
    </modules>
</debug>

With Boost.PropertyTree it is possible to iterate over the children of a node:

BOOST_FOREACH(ptree::value_type &v, pt.get_child("debug.modules"))
{
}

But since an attribute is considered as a child too, the first child of "modules" would be "group" but not a "module". Is there any way to select only child nodes of a property tree? One possibility would be to check for

if(v.first == "module")

but is there any better way?


Aucun commentaire:

Enregistrer un commentaire