my $xp = XML::XPath->new( filename => $_[0] ); my $nodeset = $xp->find('//dependency[not(child::version)] '); # find all authors foreach my $node ( $nodeset->get_nodelist ) { print XML::XPath::XMLParser::as_string($node)."\n\n"; }