+ def results
+ @place_name = params[:place_name]
+ res_hash = {}
+ @res_ary = []
+ begin
+ Net::HTTP.start('ws.geonames.org') do |http|
+ res = http.get("/search?q=#{@place_name}&maxRows=10")
+ xml = REXML::Document.new(res.body)
+ xml.elements.each("geonames/geoname") do |ele|
+ res_hash = {}
+ ele.elements.each("name"){ |n| res_hash['name'] = n.text }
+ ele.elements.each("countryCode"){ |n| res_hash['countrycode'] = n.text }
+ ele.elements.each("countryName"){ |n| res_hash['countryname'] = n.text }
+ ele.elements.each("lat"){ |n| res_hash['lat'] = n.text }
+ ele.elements.each("lng"){ |n| res_hash['lon']= n.text }
+ @res_ary << res_hash
+ end
+ end
+ rescue
+ #Flash a notice to say that geonames is broken
+ redirect_to "/index.html"
+ end