use XML::XPath; # ## create object my $xml = XML::XPath->new(filename => '/sources/sample.xml'); # foreach my $row ($xml->findnodes('/touchResult/scanResult')) { my $success = $row->find('success')->string_value; my $portResponse = $row->find('portResponse')->string_value; my $localTime = $row->find('localTime')->string_value; ....; }