in reply to Parsing NWS Public Alerts in CAP/ATOM
Ok
So here is what I have:
#!/usr/bin/perl use strict; use warnings; use LWP::Simple; use XML::Simple; # use XML::LibXML; use POSIX qw(strftime); no warnings 'uninitialized'; use Data::Dumper; my $data_dir = "/weatherdata"; my $current_file = 'SDC095.xml'; my $current = XMLin($current_file); # These seem to work if there is no active alert # my $warntitle = $current->{'entry'}->{'title'}; # my $warnlink = $current->{'entry'}->{'id'}; # my $warntext = $current->{'entry'}->{'summary'}; # These work if I already know the full URL for the alert my $warntitle = $current->{'entry'}->{'http://alerts.weather.gov/cap/w +wacapget.php?x=SD124CB88C681C.SpecialWeatherStatement.124CB88C9184SD. +UNRSPSUNR.046ee1fda521a403079118865edf9ad4'}->{'title'}; my $warnlink = $current->{'entry'}->{'http://alerts.weather.gov/cap/ww +acapget.php?x=SD124CB88C681C.SpecialWeatherStatement.124CB88C9184SD.U +NRSPSUNR.046ee1fda521a403079118865edf9ad4'}->{'id'}; my $warntext = $current->{'entry'}->{'http://alerts.weather.gov/cap/ww +acapget.php?x=SD124CB88C681C.SpecialWeatherStatement.124CB88C9184SD.U +NRSPSUNR.046ee1fda521a403079118865edf9ad4'}->{'summary'}; print "$warntitle\n"; print "$warnlink\n"; print "$warntext\n"; # print output # print Dumper($current);
And here is the XML file:
https://dl.dropbox.com/u/2859483/SDC095.xml
It wont let me post it as code in this message
So, usually if there is no warnings in the area, I get the data ok, but in this case, instead of the second tier being 'title' 'id' and 'summary' those are being pushed to the third tier, and the second tier key is now 'http://alerts.weather.gov/cap/wwacapget.php?x=SD124CB88C681C.SpecialWeatherStatement.124CB88C9184SD.UNRSPSUNR.046ee1fda521a403079118865edf9ad4' and since I do not know that in advance, it's hard to get results that way.
John
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Parsing NWS Public Alerts in CAP/ATOM
by GrandFather (Saint) on Jul 23, 2012 at 04:06 UTC | |
|
Re^2: Parsing NWS Public Alerts in CAP/ATOM
by Anonymous Monk on Jul 23, 2012 at 06:32 UTC | |
|
Re^2: Parsing NWS Public Alerts in CAP/ATOM
by johnfl68 (Scribe) on Jul 25, 2012 at 06:48 UTC |