XML::Parser::YahooRESTGeocode 0.1 review

Download
by rbytes.net on

SYNOPPSIS use LWP::Simple use XML::Parser; use XML::Parser::YahooRESTGeocode; #connec

License: Perl Artistic License
File size: 3K
Developer: Andrew N. Hicox
0 stars award from rbytes.net

SYNOPPSIS

use LWP::Simple
use XML::Parser;
use XML::Parser::YahooRESTGeocode;

#connect to yahoo geocode service
my $url = 'http://api.local.yahoo.com/MapsService/V1/geocode';
my $get = 'appid=YahooDemo&street=701+First+Street&city=Sunnyvale&state=CA';

#call yahoo geocode service
my $xml = get $url . "?" . $get;

#construct use XML::Parser with YahooRESTGeocode subclass
my $parser = new XML::Parser(Style => 'YahooRESTGeocode');
my $data = $parser->parse($xml) || do {
die ("parse failed: $XML::Parser::errstr, $!n");
};

#use the data for something
my $cnt = 0;
foreach my $result (@{$data->{'Result'}}){
$cnt ++;
print "n---- RESULT #" . $cnt . " ----n";
foreach my $field (keys %{$result}){
print "t[" . $field . "]: " . $result->{$field} . "n";
}
}

NOTES

works for geocode only

this module only knows how to handle Yahoo!'s REST responses from the geocode API

known fields

this module will need to be modified if more fields are added to the node, namely, their names will need to be added to the %node_tree hash at the top of the module

this was a quick hack

hey, maybe there's a better module for parsing REST query responses out there? This module was written as a quick hack, not as a one stop solution. If you want to add improvements or what have you, then please feel free to hack away on this 'till you're blue in the face. Send me the changes though, so I can put 'em in the distribution.

'make test' dosen't really test anything

well ... it's a quick hack. part of writing a quick hack is not writing proper test cases and skimping on documentation, speaking of ... why am I still writing ???

thanks to Yahoo!

Hey, Yahoo! Thanks for your geocode API, it's pretty sweet!

Requirements:
Perl

XML::Parser::YahooRESTGeocode 0.1 keywords