in reply to trying to understand xml::twig and also trying to learn how to extract attribute
use strict; use warnings; use Data::Dumper; use XML::Twig; my $xmlStr = <<XML; <config> <one id="msn" type="shopping"> <traffic> <daily value="on" /> <weekly value="off" /> <monthly value="off" /> </traffic> </one> <one id="movies" type="entertainment"> <traffic> <daily value="on" /> <weekly value="off" /> <monthly value="on" /> </traffic> </one> <one id="espn" type="sports"> <traffic> <daily value="on" /> <weekly value="on" /> <monthly value="on" /> <hyper value="true" /> </traffic> </one> </config> XML my @ids; my $t = XML::Twig->new(); $t->parse($xmlStr); for my $one ($t->root()->children('one')) { push @ids, $one->att('id'); } print Dumper(\@ids); __END__ $VAR1 = [ 'msn', 'movies', 'espn' ];
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: trying to understand xml::twig and also trying to learn how to extract attribute
by GrandFather (Saint) on Nov 05, 2008 at 02:05 UTC | |
by convenientstore (Pilgrim) on Nov 05, 2008 at 20:00 UTC | |
by GrandFather (Saint) on Nov 05, 2008 at 20:18 UTC | |
by toolic (Bishop) on Nov 05, 2008 at 21:02 UTC | |
by convenientstore (Pilgrim) on Nov 05, 2008 at 22:31 UTC | |
by convenientstore (Pilgrim) on Nov 06, 2008 at 15:03 UTC |