$ cat pm_1231805_to_hash.pl #!/usr/bin/perl -w use strict; use warnings; use 5.24.1; use Data::Dumper qw(Dumper); use XML::Mini::Document; $Data::Dumper::Terse=1; my $xml = <0.00 Moncton NB Canada someone\@somewhere.com CA New Brunswick 5065551212 Joe 123 Somestreet E4E 4E4 Blow EOXML my($hash_ref)=&convert_xml_to_hash($xml); my $data=eval($hash_ref); say Dumper($data); exit; sub convert_xml_to_hash { my($xml)=(@_); my($hash)={}; if($xml) { my($xml_object)=XML::Mini::Document->new(); $xml_object->parse($xml); my($output)=$xml_object->toHash(); $hash=Dumper($output); } return($hash); } Roboticus@Waubli ~ $ perl pm_1231805_to_hash.pl { 'shipping_tax' => '0.00', 'fee_lines' => '', 'billing_address' => { 'province' => 'New Brunswick', 'country' => 'Canada', 'address_2' => '', 'last_name' => 'Blow', 'company_name' => '', 'province_code' => 'NB', 'phone' => '5065551212', 'country_code' => 'CA', 'email' => 'someone@somewhere.com', 'postal_code' => 'E4E 4E4', 'city' => 'Moncton', 'address_1' => '123 Somestreet', 'first_name' => 'Joe' } } #### #!/usr/bin/perl -w use warnings; use strict; use XML::Mini::Document; use 5.24.1; my $xmlDoc = XML::Mini::Document->new(); my $data = { 'billing_address' => { 'province' => 'New Brunswick', 'city' => 'Moncton', 'company_name' => '', # Should be company_name 'phone' => '5065551212', 'address_2' => '', # Should be address_2 'country_code' => 'CA', 'first_name' => 'Joe', 'address_1' => '123 Somestreet', 'email' => 'someone@somewhere.com', 'country' => 'Canada', 'postal_code' => 'E4E 4E4', 'last_name' => 'Blow', 'province_code' => 'NB' }, 'fee_lines' => '', # should be fee_lines 'shipping_tax' => '0.00', }; $xmlDoc->fromHash($data); print $xmlDoc->toString();