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.


In reply to Re^2: Problem Parsing XML with Perl by Perobl
in thread Problem Parsing XML with Perl by Perobl

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.