Posted By

almazom on 05/10/10


Tagged

ruby parser weather


Versions (?)

weather parsing


 / Published in: Rails
 

  1. require 'net/http'
  2. require 'rexml/document'
  3.  
  4.  
  5. url = 'http://weather.yahooapis.com/forecastrss?p=RSXX0438&u=c'
  6.  
  7.  
  8. xml_data = Net::HTTP.get_response(URI.parse(url)).body
  9.  
  10.  
  11. doc = REXML::Document.new(xml_data)
  12. titles = []
  13.  
  14. doc.elements.each('rss/channel/item/yweather:condition') do |ele|
  15. print ele.attributes['temp']
  16. end

Report this snippet  

You need to login to post a comment.