use XML::LibXML; my $p = XML::LibXML->new(); my $doc = $p->parse_string(< EOT my $root = $doc->getDocumentElement(); for my $attr ($root->findnodes('//element/@*') print $attr->nodeName(),"\n"; }