use XML::LibXML; my $parser = XML::LibXML->new(); my $doc = $parser->parse_string(<<'EOT'); EOT foreach my $node ($doc->findnodes('//Paths/*') ) { print $node->nodeName(), ($node->attributes())[0]->nodeValue(),"\n"; }