Hi,

If I submit the following address to Google's geocode service:
600 Naito Parkway, Portland, OR 97209

.. I get two addresses returned (as expected)

The two addresses returned are:
600 SW Naito Pkwy, Portland, OR 97209, USA (Thoroughfare: 600 SW Naito Pkwy)
600 NW Naito Pkwy, Portland, OR 97209, USA (Thoroughfare: 600 NW Naito Pkwy)

Here's the Google geocode response link:
http://maps.google.com/maps/geo?q=600%20Naito%20Parkway,%20Portland,%20OR%20&key=ABQIAAAAzMUFFnT9uH0xq39J0Y4kbhTJQa0g3IQ9GZqIMmInSLzwtGDKaBR6j135zrztfTGVOm2QlWnkaidDIQ&output=xml

I want to parse this xml response to extract each thoroughfare element
(the address without the city, state, and zipcode).   However, the
code I'm using, which is basically lifted from the ym4r gem's Geocode
module (because I'm having the same problem with it..) is returning
the same thoroughfare twice.  I'm sure it's just not using REXML
correctly.  Here's my code..

require 'rexml/document'
require 'open-uri'

url = 
"http://maps.google.com/maps/geo?q=600%20Naito%20Parkway,%20Portland,%20OR%20&key=ABQIAAAAzMUFFnT9uH0xq39J0Y4kbhTJQa0g3IQ9GZqIMmInSLzwtGDKaBR6j135zrztfTGVOm2QlWnkaidDIQ&output=xml";
xml = open(url).read
doc = REXML::Document.new(xml)
response = doc.elements['//Response']
response.elements.each("Placemark") do |placemark|
  data = placemark.elements
  data_thoroughfare = data['//ThoroughfareName']
  puts data_thoroughfare.text
end

The output is:
600 SW Naito Pkwy
600 SW Naito Pkwy

Any idea how I can correctly grab each thoroughfare?

Thanks,
Bryan
_______________________________________________
PDXRuby mailing list
[email protected]
IRC: #pdx.rb on irc.freenode.net
http://lists.pdxruby.org/mailman/listinfo/pdxruby

Reply via email to