Bugz has asked for the wisdom of the Perl Monks concerning the following question:
Using XML::Simple, I was able to convert it to basic XML as follows$FIELDS = { 'AA' => { 'Description' => '', 'Type' => 'Module', 'File' => 'Sample1.pl', }, 'BB' => { 'Description' => 'Initiator', 'Type' => 'Methods', 'File' => 'Sample1.pl', }, 'CC' => { 'Description' => 'Destructor', 'Type' => 'Methods', 'File' => 'Sample2.pl', 'Values' => { '1' => 'Ignore', '2' => 'Retry', '3' => 'Abort' } },
As you can see the XML tags <1> <2> <3> would be illegal, so I want to convert the data to something like following:<?xml version = "1.0"?> <data> <AA> <Description></Description> <Type>Module</Type> <File>Sample1.pl</File> </AA> <BB> <Description>Initiator</Description> <Type>Methods</Type> <File>Sample1.pl</File> </BB> <CC> <Description>Destructor</Description> <Type>Methods</Type> <File>Sample2.pl</File> <Value> <1>Ignore</1> <2>Retry</2> <3>Abort</3> </Value> </C> </data>
I am unsure of how XML::Writer or XML::Twig could be able to parse the Perl Hash into the XML structure I need. Any Suggestions?<?xml version = "1.0"?> <data> <Node No='1' Label='AA'> <Description></Description> <Type>Module</Type> <File>Sample1.pl</File> </Node> <Node No= '2' Label='BB'> <Description>Initiator</Description> <Type>Methods</Type> <File>Sample1.pl</File> </Node> <Node No='3' Label='CC'> <Description>Destructor</Description> <Type>Methods</Type> <File>Sample2.pl</File> <Value No='1'>Ignore</Value> <Value No='2'>Retry</Value> <Value No='3'>Abort</Value> </Node> </data>
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Help with Perl and XML
by leonardohelman (Initiate) on Apr 25, 2008 at 20:00 UTC | |
|
Re: Help with Perl and XML
by mr_mischief (Monsignor) on Apr 25, 2008 at 19:57 UTC | |
|
Re: Help with Perl and XML
by apl (Monsignor) on Apr 25, 2008 at 19:58 UTC |