jdtoronto has asked for the wisdom of the Perl Monks concerning the following question:
Seems my brain is rather fritzed on this problem right now. I have this hash (from Data::Dumper and shortened for clarity):
Which I need to convert to XML that looks like this:$VAR1 = { 'campaign' => { 'menuid' => '10118', 'action' => 0, 'phonenumbers' => [ { 'phonenumber' => { 'number' => '9163723752' } }, { 'phonenumber' => { 'number' => '9166413900' } } ] } };
But which comes out like this:<campaign action="0" menuid="10118"> <phonenumbers> <phonenumber number="9163723752" /> <phonenumber number="9166413900" /> </phonenumbers> </campaign>
My code looks like this:<campaign action="0" menuid="10118"> <phonenumbers name="phonenumber" number="9163723752" /> <phonenumbers name="phonenumber" number="9166413900" /> </campaign>
But it seems to make no difference what I do with the ForceArray option at all!print Dumper $xml_hash; my $xml_obj = XML::Simple->new( Keeproot => 1, ForceArray => 1); my $xmlo = $xml_obj->XMLout( $xml_hash ); print $xmlo;
Any help appreciated! jdtoronto
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Yet another XML::Simple question!
by ikegami (Patriarch) on Jul 19, 2005 at 19:52 UTC | |
by jdtoronto (Prior) on Jul 19, 2005 at 20:05 UTC | |
by ikegami (Patriarch) on Jul 19, 2005 at 20:10 UTC | |
|
Re: Yet another XML::Simple question!
by gellyfish (Monsignor) on Jul 19, 2005 at 20:11 UTC |