So I've got code that works if I treat what I want to be attributes as elements. Here is an example of what I'm talking about.
SomeFile.xml
1 2 3 4 5 6 7 8
//...
<Node>
<Type>XET</Type>
<Reference>00110232</Reference>
<Date>02-09-2012</Date>
//..More stuff in node...
</Node>
<Node>//... Thousands of nodes ...
What I would like to do is have the Type and Reference be an attribute for Node.
1 2
<Node Type="XET" Reference="00110232">
//...
In my code I've got a loop like this, which works fine:
1 2 3 4 5 6 7 8 9 10 11
BOOST_FOREACH(pt_value_type &ele, pt.get_child(element::root))
{
if(ele.first == element::node)
{
std::string type = ele.second.get_child(element::name).data();
std::string reference = ele.second.get_child(element::reference).data();
//... Doing other things
parseNodeDefaults(ele, tree);
//...
}
}
What I really want to do is still loop but while parsing pull out or check the attributes for the node. My problem is the Boost::property_tree::ptree::value_type doesn't seem to have a mechanism for me to do this. I know how I can pull the value out of a ptree but not a ptree::value_type. Is there a way to do what I'm describing with a value_type?