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/