#!/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();