in reply to Looping through nodes

In your inner loop you must not use absolute pathes but relative like this:

use strict; use warnings; use XML::LibXML; foreach my $filename (@ARGV) { my $parser = XML::LibXML->new(); my $doc = $parser->parse_file($filename); foreach my $person ($doc->findnodes('/edgarSubmission/relatedPersons +List/relatedPersonInfo/relatedPersonName')){ print $_->data . " " for $person->findnodes('firstName/text()'); + print $_->data . " " for $person->findnodes('lastName/text()'); + print "\n"; } }