in reply to Parsing SOAP::Lite results
G'day Roboz,
You effectively have arrays nested within arrays, so you'll need some sort of nested loops to read the data.
If you change
foreach my $e (@{$getToysResults->{Toys}{Toy}}){ print "$e->{ToyLocations}{ToyLocation}{locationName}\n"; }
to
foreach my $e (@{$getToysResults->{Toys}{Toy}}) { my $location_array_ref = $e->{ToyLocations}{ToyLocation}; for my $location_array_hash_ref (@$location_array_ref) { print $location_array_hash_ref->{locationName}, "\n"; } }
you'll get the results you're after.
[Aside: On first viewing, I found your naming conventions somewhat counter-intuitive: Toys and ToyLocations are both plural but point to single objects; Toy and ToyLocation are both singular but point to (potentially) multiple objects. In the context of the Dumper output, it's fairly easy to see what's intended; in isolation, those names may easily lead to problems of misinterpretation (particularly if you or someone else revisits the code 12 months down the track).]
-- Ken
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Parsing SOAP::Lite results
by Roboz (Novice) on Sep 28, 2012 at 11:14 UTC | |
by kcott (Archbishop) on Sep 28, 2012 at 12:05 UTC | |
by Roboz (Novice) on Sep 28, 2012 at 12:52 UTC | |
by kcott (Archbishop) on Sep 28, 2012 at 13:21 UTC | |
by Roboz (Novice) on Sep 28, 2012 at 13:44 UTC | |
| |
by Anonymous Monk on Sep 28, 2012 at 12:57 UTC | |
by 2teez (Vicar) on Sep 28, 2012 at 12:16 UTC |