in reply to Re: Problem Parsing XML with Perl
in thread Problem Parsing XML with Perl
Thanks for the suggestion.
It looks like the [-1] forces retrieval of an earlier URL. I tried this, but this morning the problem has vanished from NOAA's XML data so I can't verify whether or not this will solve the problem.
I thought I could maybe do the following:
if (exists $data->{'data'}->{'parameters'}->{'conditions-icon'}->{'ico +n-link'}->[0]) { $weatherIconURL = $data->{'data'}->{'parameters'}->{'condi +tions-icon'}->{'icon-link'}->[0]; print "Weather Icon: ", $data->{'data'}->{'parameters'}->{ +'conditions-icon'}->{'icon-link'}->[0], "\n"; } else { $weatherIconURL = $data->{'data'}->{'parameters'}->{'condi +tions-icon'}->{'icon-link'}->[-1]; print "Weather Icon: ", $data->{'data'}->{'parameters'}->{ +'conditions-icon'}->{'icon-link'}->[-1], "\n"; }
Do you think this will correctly handle the NIL exceptions?
|
|---|