I am using XML::Simple for parsing a XML file. Code is given below with XML file,
use Tie::IxHash;
tie %$data, "Tie::IxHash";
use XML::Simple;
use Data::Dumper;
$xml = new XML::Simple;
$data = $xml->XMLin("ship_order.xml");
print Dumper($data);
XML file, (ship_order.xml)
<?xml version="1.0" encoding="UTF-8" ?>
<shipment>
<shiptoaddress>
<name>Prasad</name>
<address>AnnaNagar</address>
</shiptoaddress>
<items>
<quantity>5</quantity>
<price>100</price>
</items>
<items>
<quantity>6</quantity>
<price>50</price>
</items>
<num_of_items>2</num_of_items>
</shipment>
Output is not coming in order, even though I am using Tie::IxHash module.
My output:
$VAR1 = {
'num_of_items' => '2',
'shiptoaddress' => {
'name' => 'Prasad',
'address' => 'AnnaNagar'
},
'items' => [
{
'quantity' => '5',
'price' => '100'
},
{
'quantity' => '6',
'price' => '50'
}
]
};