in reply to Re^2: Perl and XML
in thread Perl and XML
Did you lather, rinse, repeat? You would have found out that the data structure you want with XML::Simple is as follows:
$FIELDS = { data => { Node => [ { No => '1', Label => 'AA', Type => { content => 'Module' }, File => { content => 'Sample1.pl'}, Description => { }, }, { No => '2', Label => 'BB', Type => { content => 'Methods' }, File => { content => 'Sample1.pl' }, Description => { content => 'Initiator' }, }, { No => '3', Label => 'CC', Type => { content => 'Methods' }, File => { content => 'Sample2.pl' }, Description => { content => 'Destructor' }, Value => [ { No => '1', content => 'Ignore', }, { No => '2', content => 'Retry', }, { No => '3', content => 'Abort', } ], } ] } };
Output:
<opt> <data> <Node Label="AA" No="1"> <Description></Description> <File>Sample1.pl</File> <Type>Module</Type> </Node> <Node Label="BB" No="2"> <Description>Initiator</Description> <File>Sample1.pl</File> <Type>Methods</Type> </Node> <Node Label="CC" No="3"> <Description>Destructor</Description> <File>Sample2.pl</File> <Type>Methods</Type> <Value No="1">Ignore</Value> <Value No="2">Retry</Value> <Value No="3">Abort</Value> </Node> </data> </opt>
Getting rid of the outer <opt> tag is left as an exercise to the reader.
As dragonchild wrote above, you need to transform your hash so as to fit the module you are using.
--shmem
_($_=" "x(1<<5)."?\n".q·/)Oo. G°\ /
/\_¯/(q /
---------------------------- \__(m.====·.(_("always off the crowd"))."·
");sub _{s./.($e="'Itrs `mnsgdq Gdbj O`qkdq")=~y/"-y/#-z/;$e.e && print}
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: Perl and XML
by Bugz (Acolyte) on Apr 29, 2008 at 19:48 UTC | |
by shmem (Chancellor) on Apr 29, 2008 at 22:17 UTC |