def geocode(address)
open(GOOGLE_MAPS_URL + "q=#{ERB::Util.url_encode(address)}") do |response|
xml = REXML::Document.new(response.read)
if xml.elements['/kml/Response/Status/code'].text == '200'
self.country_code = xml.elements['/kml/Response/Placemark/AddressDetails/Country/CountryNameCode'].text
self.address_line = xml.elements['/kml/Response/Placemark/AddressDetails/Country/AddressLine'].text
geocode_array = xml.elements['/kml/Response/Placemark/Point/coordinates'].text.split(/,/)
self.latitude = geocode_array[0]
self.longitude = geocode_array[1]
end
end
end