Boost logo

Boost :

From: Marcin Kalicinski (kalita_at_[hidden])
Date: 2006-04-26 18:04:39


>>http://msdn.microsoft.com/visualc/rss.xml
>>
> Parses and displays fine for me. That's without my patch.
>
>>So, what is the code to read the multiple titles ? This is my oversight
>>for
>>not looking at this in more detail
>>
> It's rather complicated. This is not what PropTree was built for, as far
> as I can see - support for multiple nodes with the same name is rather
> weak.

I would not say it was not built for it - it is a legitimate use. It may
rather indicate that ptree interface is lacking something with regards to
multiple nodes with the same name. But maybe it's not that bad, see below.

>Path resolution always takes the first that comes up. It's not an
> XPath engine - not by far.
> The steps to take in this specific case would be:
> 1) Get the child "rss.channel".
> 2) Call sort() on the channel. (Marcin, is sort() stable, i.e. would it

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';

Best regards,
Marcin


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk