use XML::XPath; my $xp = XML::XPath->new(ioref => \*DATA); my $nodeset = $xp->find('/track/el/attribute[@name="type"]/text()'); # foreach my $node ($nodeset->get_nodelist) { print "FOUND\n\n", $node->getValue, "\n\n"; }