use strict; use warnings; use Data::Dumper; use XML::Twig; my $xmlStr = < 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' ];