#!/usr/bin/perl use strict; use warnings; use XML::Simple; use Data::Dumper; my $xml_simple = XML::Simple->new( KeepRoot => 1, KeyAttr => 1, ForceArray => 1 ); my $response_hash = eval{ $xml_simple->XMLin( "cars.xml" ) }; print Dumper($response_hash); Output : $VAR1 = { 'root' => [ { 'unsold' => [ { 'car' => [ { 'model' => [ 'Hyundai' ], 'mileage' => [ '20000' ] }, { 'model' => [ 'Jeep' ], 'mileage' => [ '10000' ] } ] } ], 'footnotes' => [ { 'footnote' => [ { 'content' => 'F1 text', 'id' => 'F1' }, { 'content' => 'F2 text', 'id' => 'F2' } ] } ] } ] };