"Johan Nilsson" wrote in message news:...
Well, something along the lines of this should work (caution: not tested): ptree technologies; /* load xml */ for (ptree::const_iterator iter = technologies.begin(); iter != technologies.end(); ++iter) { std::cout << "ID: " << (*iter).getstd::string("<xmlattr>.ID") << '\n' } HTH // Johan
Unfortunally this does not work, *iter returns ptree::value_type, so even if I could do std::cout << "ID: " << (*iter).second.getstd::string("<xmlattr>.ID") << '\n', it will throw "ptree_bad_path" because it can't find the key. It will also throw with get("Technologies.Logistics") and get_child(...). Even worse is that incrementing my iterator from my root node will cause iter.begin == iter.end, and if I try ptree.find("<xmlattr>.ID") or ptree.find("Technologies.Logistics") it will return an invalid iterator. The only thing that even works is the following code, except it will only print out the topmost node. I need to be able to print out the whole tree and their respective children. BOOST_FOREACH(ptree::value_type &v, pt.get_child("Technologies.Logistics")) print(v.second.data()); <Tech> <Logistics> <somedata>1.0</somedata> </Logistics> /* stops here */ <Logistics> ... Unless someone knows of a similar lightweight XML parser that allows me to iterate through the tree, I would greatly appreciate any help with property_tree.