Parsing an RSS feed with Ruby
Published on June 9, 2007
Parsing an RSS feed is insanely simple with Ruby. Two lines is all it takes. . .
require 'rss'
rss = RSS::Parser.parse(open('http://www.travisonrails.com/feed/posts').read, false)
Now you'll have an Array of the results, so you can do something like:
rss.items.each { |i| puts "#{i.title} - #{i.date}" }
Thank you, this is just the code snippet I need to begin pulling news headlines into an upcoming project.
Leave a comment:
©2008 Travis Roberts. All rights reserved.
![Validate this page for XHTML [Valid XHTML]](/images/xhtml.gif)
![Validate this page for CSS [Valid CSS]](/images/css.gif)
![Validate my RSS feed [Valid RSS]](/images/rss.gif)
Nick said on June 21, 2007:
Thanks, so very very simple.