use strict; use warnings; use XML::LibXML; my $filename = $ARGV[0]; my $parser = XML::LibXML->new(); my $doc = $parser->parse_file($filename); my $xc = XML::LibXML::XPathContext->new( $doc->documentElement() ); foreach my $sections ($xc->findnodes('/HOSTNAME/PATROL/ACL/USERNAME')) { my($username) = $sections->getAttribute('name'); my($permissions) = $sections->findnodes('./PERMISSION'); my($host) = $sections->findnodes('./HOST'); print $username->to_literal, "\n"; print $permissions->to_literal, "\n"; print $host->to_literal, "\n"; }