in reply to Parsing multiple XML and Store the values into hashmap as Key/Value Pair
Hi there, this should get you going:
use strict; use warnings; use XML::Hash; use Data::Dumper; my %data; open my $xmldata, '<', 'file.xml' or die $!; for my $product (values XML::Hash->new()->fromXMLStringtoHash($xmldata +)) { my ($product, $license, $id, $code, $name) = ( $product->{productName}->{text}, $product->{licenseName}->{text}, $product->{externalProductIdentifier}->{text}, $product->{baseCode}->{text}, $product->{name}); $data{$license} = [ $product, $id, $code, $name ]; } print Dumper \%data/
Output when run against your example xml:
$VAR1 = { 'Airtime_Tool' => [ 'Airtime', '10', 'AT', 'aero' ] };
*Updated the code to store into a hash map
|
|---|