in reply to Get data from an XML file heading
It doesn't look like XML to me.
It does to me, unless you're not showing everything.
If not, I guess a RegEx would be the way to go.
No, please don't!! Parsing HTML/XML with Regular Expressions
use warnings; use strict; use XML::LibXML; my $xml = <<'END_XML'; <root> <result_summary 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" /> </root> END_XML my $dom = XML::LibXML->load_xml(string => $xml); my @nodes = $dom->findnodes('//result_summary'); die "Failed to find exactly one result_summary node" unless @nodes==1; my %attrs = %{ $nodes[0] }; use Data::Dumper; print Dumper(\%attrs); __END__ $VAR1 = { 'total_records' => '594', 'feed_version' => '1.44', 'time_start' => '2020-02-19 15:50:55', 'download_key' => 'xmxnxnxnxnxnxnxnxnx', 'total_pages' => '3', 'records_this_page' => '250', 'current_page' => '1' };
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Get data from an XML file heading
by nachtmsk (Acolyte) on Feb 20, 2020 at 15:58 UTC | |
by haukex (Archbishop) on Feb 20, 2020 at 16:13 UTC | |
by nachtmsk (Acolyte) on Feb 20, 2020 at 17:10 UTC | |
by haukex (Archbishop) on Feb 20, 2020 at 17:47 UTC |