# Parsing multiple RSS & Atom feed formats

**URL:** <https://www.ruby-forum.com/t/parsing-multiple-rss-atom-feed-formats/132454>\
**Category:** Rails\
**Created:** [March 20, 2008, 10:36am UTC](https://www.ruby-forum.com/t/parsing-multiple-rss-atom-feed-formats/132454 "2008-03-20T10:36:17Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![chunkyslink](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/f0a364/32.png) [@chunkyslink](https://www.ruby-forum.com/u/chunkyslink)\
**Post date:** [March 20, 2008, 10:36am UTC](https://www.ruby-forum.com/t/parsing-multiple-rss-atom-feed-formats/132454/1 "2008-03-20T10:36:17Z")

</div>

I’m working on a RSS aggregator, and I’ve based the parser on a script  
from this post;

[http://www.superwick.com/archives/2007/06/09/rss-feed-parsing-in-ruby-on-rails/](http://www.superwick.com/archives/2007/06/09/rss-feed-parsing-in-ruby-on-rails/)

But, being the complete newbie, I’ve found that this parser only works  
for specifically formatted feeds. For example, some feeds will throw a  
‘nil text’ error. I know that I could make this script handle ‘nil’  
attributes, but I’m betting that someone out there has already found a  
good solution for handling all Atom/RSS1.0/RSS2.0 formats.

I’ve scoured Google, but there only seems to be snippets or short posts  
on how to handle individual feeds or one type of format. Would anyone be  
able to enlighten me on this one? Are there any glaringly  
well-documented snippets, gems, plugins, tutorials, or books which I’m  
completely missing?

---

<div class="post-metadata">

**Author:** ![chunkyslink](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/f0a364/32.png) [@chunkyslink](https://www.ruby-forum.com/u/chunkyslink)\
**Post date:** [March 20, 2008, 6:38pm UTC](https://www.ruby-forum.com/t/parsing-multiple-rss-atom-feed-formats/132454/2 "2008-03-20T18:38:39Z")

</div>

> I’ve scoured Google, but there only seems to be snippets or short posts  
> on how to handle individual feeds or one type of format. Would anyone be  
> able to enlighten me on this one? Are there any glaringly  
> well-documented snippets, gems, plugins, tutorials, or books which I’m  
> completely missing?

[http://simple-rss.rubyforge.org/](http://simple-rss.rubyforge.org/)

---

<div class="post-metadata">

**Author:** ![chunkyslink](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/f0a364/32.png) [@chunkyslink](https://www.ruby-forum.com/u/chunkyslink)\
**Post date:** [March 22, 2008, 11:04am UTC](https://www.ruby-forum.com/t/parsing-multiple-rss-atom-feed-formats/132454/3 "2008-03-22T11:04:12Z")

</div>

> I’ve tried usual fixes of captial letters etc, but no luck…

That’s because open-uri is part of the ruby standard library, rather  
than a gem. Just “require ‘open-uri’” in your script/application and  
you’re good to go.

SimpleRSS does take care of some of the difficulties of parsing multiple  
feeds, and does take care of the atom/RSS differences. You still might  
need some conditional or chained assignment to deal with things like the  
publishing date. (Is it ? ? dc:date? or whatever  
else …?)

hth  
Jon

---

<div class="post-metadata">

**Author:** ![chunkyslink](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/f0a364/32.png) [@chunkyslink](https://www.ruby-forum.com/u/chunkyslink)\
**Post date:** [March 22, 2008, 10:32am UTC](https://www.ruby-forum.com/t/parsing-multiple-rss-atom-feed-formats/132454/4 "2008-03-22T10:32:11Z")

</div>

Philip H. wrote:

> > I’ve scoured Google, but there only seems to be snippets or short posts  
> > on how to handle individual feeds or one type of format. Would anyone be  
> > able to enlighten me on this one? Are there any glaringly  
> > well-documented snippets, gems, plugins, tutorials, or books which I’m  
> > completely missing?
> 
> [http://simple-rss.rubyforge.org/](http://simple-rss.rubyforge.org/)

Thanks Philip.

I’ve seen simple-rss, I just haven’t come across a definitive example of  
how to pull down all elements of a feed, like in the tutorial link in  
the original post. Am I right in presuming I can use simple-rss to  
handle all feeds in place of the RSSParser defined in the aforementioned  
link, so I just need to write one parser, rather than conditionals for  
Atom/RSS?

I’m actually having problems installing the open-uri gem;

“could not find open-uri locally or in a repository”

I’ve tried usual fixes of captial letters etc, but no luck…

---

<div class="post-metadata">

**Author:** ![chunkyslink](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/f0a364/32.png) [@chunkyslink](https://www.ruby-forum.com/u/chunkyslink)\
**Post date:** [March 23, 2008, 1:37pm UTC](https://www.ruby-forum.com/t/parsing-multiple-rss-atom-feed-formats/132454/5 "2008-03-23T13:37:32Z")

</div>

Jonathan Stott wrote:

> > I’ve tried usual fixes of captial letters etc, but no luck…
> 
> That’s because open-uri is part of the ruby standard library, rather  
> than a gem. Just “require ‘open-uri’” in your script/application and  
> you’re good to go.
> 
> SimpleRSS does take care of some of the difficulties of parsing multiple  
> feeds, and does take care of the atom/RSS differences. You still might  
> need some conditional or chained assignment to deal with things like the  
> publishing date. (Is it ? ? dc:date? or whatever  
> else …?)
> 
> hth  
> Jon

That helps, thanks Jon. I definitely needed some clarification on how  
streamlined I could expect the parser to be, and I’ve only seen pubDate  
so far, so that example was useful.

At the risk of sounding like a lazy fool, I’m quite suprised there isn’t  
a one-stop chunk of Ruby code for parsing generic blog post feeds and  
handling the differences in Atom/RSS (like publishing date) out there.  
If I work it out I’ll be sure to share it.

---

<div class="post-metadata">

**Author:** ![chunkyslink](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/f0a364/32.png) [@chunkyslink](https://www.ruby-forum.com/u/chunkyslink)\
**Post date:** [May 9, 2008, 8:33pm UTC](https://www.ruby-forum.com/t/parsing-multiple-rss-atom-feed-formats/132454/6 "2008-05-09T20:33:42Z")

</div>

I’ve also had really good luck with FeedTools.

Jamey

---

<div class="post-metadata">

**Author:** ![chunkyslink](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/f0a364/32.png) [@chunkyslink](https://www.ruby-forum.com/u/chunkyslink)\
**Post date:** [May 9, 2008, 8:27pm UTC](https://www.ruby-forum.com/t/parsing-multiple-rss-atom-feed-formats/132454/7 "2008-05-09T20:27:51Z")

</div>

Feed normalizer might work for you.  
[http://code.google.com/p/feed-normalizer/](http://code.google.com/p/feed-normalizer/)

On Mar 23, 8:37 am, Neil C. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)
