ralibm has asked for the wisdom of the Perl Monks concerning the following question:
What I want is the description of Item1. So I have something like this to capture the data.$VAR1 = { 'Stuff1' => 'Data Stuff', 'ImportantStuff' => { 'MoreStuff' => { ... }, 'VeryImportantStuff' => { 'Item1' => { 'Description' => 'Need To Know', 'Date' => '20040101', }, 'Item2' => { ... }, 'Item3' => { ... }, }, }, };
Then I get the following output:#pseudo code struct SubFields => { Description => '$', Date => '$', }; my $s = XML::Simple->new; my $tree = $s->XMLin($someFile); my $subfields = SubFields->new(); $subfields->Description ( $tree->{ImportantStuff}->{VeryImportantStuff +}->{Item1}->{Description} ); print Dumper($subfields); print Dumper($tree);
As you can see the data was not retrieved, and the tree now has a new empty entry.$VAR1 = bless({ 'SubFields::Description' => undef, 'SubFields::Date' => undef, }, 'SubFields'); $VAR1 = { 'ImportantStuff' => { 'VeryImportantStuff' => { 'Item1' => {} } }, }, 'Stuff1' => 'Data Stuff', 'ImportantStuff' => { 'MoreStuff' => { ... }, 'VeryImportantStuff' => { 'Item1' => { 'Description' => 'Need To Know', 'Date' => '20040101', }, 'Item2' => { ... }, 'Item3' => { ... }, }, }, };
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: XML::Simple Hashes of Ref's of Hashs of Ref's...
by PodMaster (Abbot) on Mar 19, 2004 at 21:16 UTC | |
by ralibm (Acolyte) on Mar 19, 2004 at 22:57 UTC | |
by PodMaster (Abbot) on Mar 19, 2004 at 23:20 UTC |