use strict; use warnings; use XML::XPath; use Data::Dumper; my @records; my $xml = 'ApplicationList.xml'; my $xp = XML::XPath->new(filename => $xml); my $nodeset = $xp->findnodes('/application_list'); foreach my $node ($nodeset->get_nodelist) { my $appid = $xp->find('./application/@id', $node); s/^\s+|\s+$//g for $appid; push @records, { appid => $appid->string_value, } } print Dumper @records; #### C:\SLB\Dashboard\Perl>perl testperl.pl $VAR1 = { 'appid' => '212' }; ####