use XML::LibXML 1.70; ## for load_html/load_xml/location my $qstat = 'qstat.xml'; my $dom = XML::LibXML->new(qw/ recover 2 /)->load_xml( location => $qstat ); for my $job ( $dom->findnodes( q{ /job_info/queue_info/Queue-List } ) ){ print $job->nodePath, "\n"; for my $slot ( $job->findnodes( q{ ./job_list/slots } ) ){ print $slot->nodePath, "\n"; print $slot, "\n"; print $slot->textContent, "\n"; } } __END__ /job_info/queue_info/Queue-List /job_info/queue_info/Queue-List/job_list/slots 1 1