in reply to Re: Problem Parsing XML with Perl
in thread Problem Parsing XML with Perl
Thanks for the help.
I'll provide some additional information about my project. My Perl program fires each and every hour and ultimately generates a text file that is used by Flash action script to automatically update a custom weather widget that is part of a larger flash welcome screen on a company intranet.
My program first connects with NOAA and then loops thru and retrieves XML weather data for multiple locations. This information is saved to individual .XML documents in my Flash source file directory. The program then creates an array from the hash pairs I tell it to collect. Finally, the array is used to create comma delineated list of data that is saved as a text file for Flash.
The Perl program also retrieves the correct weather graphic (.JPG files) from NOAA for use in the Flash action script. I have Perl do this because of security restrictions in Flash. The images reference the URL provided in the XML data.
My Perl code for connecting to NOAA follows:
# call NDFgenByDay to retrieve the xml forecast data print "\n\nCalling NDFgenByDay to retrieve XML forecast data f +or ", $location[$i], " ... "; my $response = $weather->call( SOAP::Data->name($method) =>SOAP::Data->type(decimal=>$latitude[$i])->name('lati +tude'), =>SOAP::Data->type(decimal=>$longitude[$i])->name('lon +gitude'), =>SOAP::Data->type(date=>$startDate)->name('startDate' +), =>SOAP::Data->type(integer=>$numDays)->name('numDays') +, =>SOAP::Data->type(string=>$format)->name('format') ); print "done.\n";
My Perl code to create the XML follows:
my $xml = $filePath . 'Forecast_' . $location[$i] . '.xml'; open(OUT, '>' . $xml); print OUT $response->result; close(OUT);
The URL is retrieved and stored as follows:
$weatherIconURL = $data->{'data'}->{'parameters'}->{'conditions-icon'} +->{'icon-link'}->[0];
The problem is 'icon-link' can't be found in certain situations. Though this seems to be rare. Nevertheless, if it occurs, my program isn't currently set up to handle it. It would be nice if I could simply deal with this situation in the existing code.
Hope this helps to better explain the problem.
|
|---|