The module uses XML :: Simple without parameters, but RootName . Knowing that, we know that the following data structure will produce the desired result.
my $data = { 'tag1' => [ { id => 'abcd', content => '4', }, { 'tag3' => [ { id => 'xyz', content => '6', }, ], }, ], };
Test:
use XML::Simple qw( XMLout ); print XMLout($data , RootName => 'data');
Output:
<data> <tag1 id="abcd">4</tag1> <tag1> <tag3 id="xyz">6</tag3> </tag1> </data>
(It will provide a response element.)
source share