use warnings; use strict; use XML::LibXML; ### https://metacpan.org/pod/distribution/XML-LibXML/LibXML.pod ### https://grantm.github.io/perl-libxml-by-example/basics.html ### https://metacpan.org/pod/distribution/XML-LibXML/lib/XML/LibXML/Element.pod ### https://metacpan.org/pod/distribution/XML-LibXML/lib/XML/LibXML/Node.pod my $dom = XML::LibXML->load_xml(string => <<'EOT'); EOT ### get individual attribute by name: print "\n******* get individual attribute by name: ***********\n"; foreach my $attribute( $dom->findnodes('/test/result_summary/@total_pages') ) { print "total_pages = ", $attribute->to_literal, "\n"; } ### get individual as hash refs: print "\n******* get individual attribute as hash refs: ***********\n"; foreach my $result_sum ( $dom->findnodes('/test/result_summary') ) { print "total_pages = ", $result_sum->{total_pages}, "\n"; } ### get all attributes: print "\n******* get all attributes: ***********\n"; foreach my $attribute( $dom->findnodes('/test/result_summary/@*') ) { print $attribute->nodeName, " = ", $attribute->to_literal, "\n"; }