[Edinburgh-pm] XML module recommendations

Marco Fontani fontani at gmail.com
Mon Jun 6 10:40:15 PDT 2011


> I'd like to extract a list of all the hashes: ie, the content of every
> attribute matching the XPath /changelog/patch/@hash. What's the best
> CPAN module for that sort of thing?

If I have no need for the "goodies" of other XML parsers, I use XML::Bare.
It's fast, to the point and doesn't try to do too much.

See http://darkpan.com/files/xml-parsing-perl-gripes.txt for my rant on the topic.

That said,

% perl -MXML::Bare -le'
   $x   = XML::Bare->new(file => $ARGV[0]);
   $xml = $x->parse;
   print $_->{hash}->{value} for @{ $xml->{changelog}->{patch} };
' test.xml

20100205002131-d1398-ec8538dd31f4962aace5ee3984568b3b3ca96527.gz
20090220012304-d1398-7af369eaf17325b5dae10db7c91db1edfc921b99.gz
20090125173648-d1398-a286dec5525eb3a8481f1e6550229090a30da4fb.gz
20080922221150-d1398-3e8da86f8e360753ea2cb267f5195e1d379d8531.gz
20080922160237-d1398-e82c426fca5a9345e9d8b86cbde01502f07fbd1f.gz

I think the above is close to what you need?

-marco-

---
Marco Fontani
Glasgow Perl Mongers - http://glasgow.pm.org/
Join the RackSpace Cloud at: http://www.rackspacecloud.com/277.html


More information about the Edinburgh-pm mailing list