Beefy Boxes and Bandwidth Generously Provided by pair Networks Joe
Problems? Is your data what you think it is?
 
PerlMonks  

Re: Parsing SOAP::Lite results

by shmem (Canon)
on Sep 28, 2012 at 10:18 UTC ( #996159=note: print w/ replies, xml ) Need Help??


in reply to Parsing SOAP::Lite results

and I get a 'Not an ARRAY reference' error. What am I doing wrong?

Well, I get a Not a HASH reference error, since $getToysResults->{Toys}->{Toy} is of type ARRAY:

$VAR1 = { 'Toys' => bless( { 'Toy' => [ <----- here ... ] }, 'ArrayOfToy' ) };

You need two loops.

for my $toy ( @{$getToysResults->{Toys}->{Toy}} ) { for my $l ( @{$toy->{ToyLocations}->{ToyLocation}} ) { print "$l->{locationName}\n" } }


Comment on Re: Parsing SOAP::Lite results
Select or Download Code
Re^2: Parsing SOAP::Lite results
by Roboz (Novice) on Sep 28, 2012 at 10:52 UTC

    I got the 'Not an ARRAY reference' error when I tried the second loop, as in your suggestion. That was the part that was confusing me.

      shmem's code should not have produced that error with the data you posted. My code (Re: Parsing SOAP::Lite results) should not have produced the same error either. I'm now reasonably certain that the data you've posted is not the data you're operating on. See my earlier response (Re^3: Parsing SOAP::Lite results) for some suggestions.

      -- Ken

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://996159]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (7)
As of 2014-04-23 11:16 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    April first is:







    Results (541 votes), past polls