
On 4/27/06, Marcin Kalicinski <kalita@poczta.onet.pl> wrote:
Sort is not stable. But I thing there is a better algorithm: iterate over all nodes and compare keys. It is O(n) instead O(n log n), plus it preserves the sequence of nodes. This will list all the titles:
BOOST_FOREACH(boost::property_tree::ptree::value_type &v, pt.get_child( argv[2] )) if (v.first == "item") std::cout << "title: " << v.second.get("title", "no title") << '\n';
Yes, this is what I was looking for. What I think is missing is a method to construct the full query path, so that you don't have to code for "item" and "title" , something like pt.get_match("rss.channel.item.title") . Also, the fact that it preserves the ordering is important (and performance is less important in this case)