use XML::XPath; use Data::Dumper; my $xpath = XML::XPath->new(ioref => *DATA); my $nodeset = $xpath->find('/type/config'); print map $_->toString, $nodeset->get_nodelist; __DATA__ BLA BLA FIRST SECOND MY TEST