use strict; use warnings; use XML::Simple; my $h_ref = { 'a' => 1, 'b' => 2, 'c' => 3, 'colors' => [ 'red', 'green', 'blue' ], 'sub_hash' => { 'numbers' => [ 0, 1, 2], 'letters' => { 'vowels' => [qw[a e i o u]], }, }, }; my $ref = "1,2,3"; my $xs = XML::Simple->new(ForceArray => 1, KeepRoot => 1, XMLDecl => 1); my $xml = $xs->XMLout($h_ref); print "XML is:\n$xml\n"; __END__ [Output] red green blue a e i o u 0 1 2