Reading the XML::Simple man page helps. Write your expected xml to a file, say, foo.xml, then read and dump it with a script named foo:
use XML::Simple; use Data::Dumper; $Data::Dumper::Indent = 1; my $config = XMLin(); print Dumper($config);
Voilà:
$VAR1 = { 'Node' => [ { 'Type' => 'Module', 'No' => '1', 'File' => 'Sample1.pl', 'Description' => {}, 'Label' => 'AA' }, { 'Type' => 'Methods', 'No' => '2', 'File' => 'Sample1.pl', 'Description' => 'Initiator', 'Label' => 'BB' }, { 'Value' => [ { 'No' => '1', 'content' => 'Ignore' }, { 'No' => '2', 'content' => 'Retry' }, { 'No' => '3', 'content' => 'Abort' } ], 'Type' => 'Methods', 'No' => '3', 'File' => 'Sample2.pl', 'Description' => 'Destructor', 'Label' => 'CC' } ] };
Lather, rinse, repeat.
--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}
In reply to Re: Perl and XML
by shmem
in thread Perl and XML
by Bugz
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |