#!/usr/bin/env perl use warnings; use strict; use Data::Dumper; my $menufile = './in.xml'; use XML::Simple qw(:strict); my $xml = XMLin($menufile,forcearray=>['item','command','exec','menu'] +,keyattr=>[],suppressempty=>undef); print Dumper($xml);
Which prints out (i.e., all "items" are arrays):
$VAR1 = { 'menu' => [ { 'item' => [ { 'label' => ' EDM ', 'type' => 'command', 'exec' => [ { 'run' => ' edmBeta ' } ] }, { 'name' => ' SoftwareMenu ', 'type' => 'submenu' } ], 'name' => 'MainMenu', 'label' => ' OPS Menu ' }, { 'item' => [ { 'name' => ' IOCMenu ', 'type' => 'submenu' } ], 'name' => 'SoftwareMenu', 'label' => ' Software Tools ' } ] };
The difference is keyattr=>[].
I honestly am not very experienced with XML::Simple, but I followed a link from the docs to XML/Simple/FAQ where it discusses "array folding".
In reply to Re: XML::Simple help
by toolic
in thread XML::Simple help
by mjoyce
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |