#<REXML::ParseException: Missing end tag for 'DependentLocalityName' (got "DependentLocality") Line: Position: Last 80 unconsumed characters: </Locality></SubAdministrativeArea></AdministrativeArea></Country></AddressDetail> /opt/ruby-enterprise-1.8.6-20080709/lib/ruby/1.8/rexml/parsers/baseparser.rb:330:in `pull'
I've checked the address we were trying to geocode "Olgastrasse 128, 70180 Stuttgart"
and it turns out that XML/KML response is not well formed (ISO-8859-1 characters with UTF-8 encoding header in XML)
Had to patch Geocoding.get to "force" utf-8 on res after read using to_utf8
url = "http://maps.google.com/maps/geo?q=#{URI.encode(request)}&key=#{api_key}&output=#{output}"
res = open(url).read
begin
res = res.to_utf8
rescue
end
case output.to_sym
After that XML was good and application happy
<?xml version="1.0" encoding="UTF-8"?> <kml xmlns="http://earth.google.com/kml/2.0"> <Response> <name>Olgastrasse 128, 70180 Stuttgart</name> <Status><code>200</code><request>geocode</request></Status> <Placemark id="p1"> <address>Olgastraße 128, 70180 Stuttgart-Süd, Stuttgart, Germany</address> <AddressDetails Accuracy="8" xmlns="urn:oasis:names:tc:ciq:xsdschema:xAL:2.0"> <Country><CountryNameCode>DE</CountryNameCode> <AdministrativeArea> <AdministrativeAreaName>Baden-Württemberg</AdministrativeAreaName> <SubAdministrativeArea> <SubAdministrativeAreaName>Stuttgart</SubAdministrativeAreaName> <Locality> <LocalityName>Stuttgart</LocalityName> <DependentLocality> <DependentLocalityName>Stuttgart-Süd</DependentLocalityName> <Thoroughfare> <ThoroughfareName>Olgastraße 128</ThoroughfareName> </Thoroughfare> <PostalCode> <PostalCodeNumber>70180</PostalCodeNumber> </PostalCode></DependentLocality> </Locality></SubAdministrativeArea> </AdministrativeArea></Country> </AddressDetails> <Point><coordinates>9.177973,48.766634,0</coordinates></Point> </Placemark></Response></kml>