Check out some of the XML tutorials online for explanations of attributes. Here are some examples of accessing attributes.

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/El +ement.pod ### https://metacpan.org/pod/distribution/XML-LibXML/lib/XML/LibXML/No +de.pod my $dom = XML::LibXML->load_xml(string => <<'EOT'); <test> <result_summary total_records="594" total_pages="3" current_page="1" + records_this_page="250" download_key="xmxnxnxnxnxnxnxnxnx" time_star +t="2020-02-19 15:50:55" feed_version="1.44" /> </test> EOT ### get individual attribute by name: print "\n******* get individual attribute by name: ***********\n"; foreach my $attribute( $dom->findnodes('/test/result_summary/@total_pa +ges') ) { 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"; }

Output:

******* get individual attribute by name: *********** total_pages = 3 ******* get individual attribute as hash refs: *********** total_pages = 3 ******* get all attributes: *********** total_records = 594 total_pages = 3 current_page = 1 records_this_page = 250 download_key = xmxnxnxnxnxnxnxnxnx time_start = 2020-02-19 15:50:55 feed_version = 1.44

In reply to Re: Get data from an XML file heading by Lotus1
in thread Get data from an XML file heading by nachtmsk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.