Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
# # This script generates the following output... # # - x - x - x - x - x - x - x - x - # $tree $VAR1 = \{ # 'banana' => { # 'value' => '1231210', # 'name' => 'date' # }, # 'apple' => { # 'time' => { # 'value' => '235959' # }, # 'date' => { # 'value' => '1231210' # } # } # }; # # # - x - x - x - x - x - x - x - x - # # How do I get the banana to to look like the apple? # # e.g. # # 'banana' => { # 'date' => { # 'value' => '1231210' # } # }, # }; # use strict; use XML::Simple; use Data::Dumper; my $text=<<EOF; <main> <apple name="date" value="1231210"/> <apple name="time" value="235959"/> <banana name="date" value="1231210"/> </main> EOF my $p1 = new XML::Simple(); my $tree; my $config = eval { $tree= $p1->XMLin($text, # ,VarAttr => 'name' # ,VarAttr => 'name', ContentKey => '-content' # ,KeyAttr => "name" # ,KeyAttr => { userdefined=>"name"} # ,KeyAttr => { userdefined=>"+name"} # ,KeyAttr => { userdefined=>"-name"} ,KeyAttr => 'name' # ,ValueAttr => {userdefined=>"name"} ) }; die("$@\n Ending") if ($@); print "\$tree " . Dumper(\$tree) . "\n"; exit 0;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: hash from xml::simple
by runrig (Abbot) on Dec 10, 2009 at 23:48 UTC | |
by Anonymous Monk on Dec 11, 2009 at 00:11 UTC | |
by ikegami (Patriarch) on Dec 11, 2009 at 01:40 UTC | |
by Anonymous Monk on Dec 11, 2009 at 13:03 UTC | |
by ikegami (Patriarch) on Dec 11, 2009 at 16:53 UTC | |
by runrig (Abbot) on Dec 11, 2009 at 22:21 UTC |