use XML::LibXML qw(); my $dom = XML::LibXML->load_xml(string => \<<'XML'); XML for my $node ($dom->findnodes('//drl[@connectionid]')) { print $node->getAttribute('connectionid'); }