Parsing atom/rss feed containing multiple <link> tags with Haml on RoR

Posted by fenderplayer on Stack Overflow See other posts from Stack Overflow or by fenderplayer
Published on 2010-03-18T11:15:30Z Indexed on 2010/03/18 12:31 UTC
Read the original article Hit count: 370

Filed under:
|
|
|

So, firstly, heres an atom feed snippet which i am trying to parse:

// http://somelink.com/atom   
<feed xmlns="http://www.w3.org/2005/Atom">
    <entry>
        <title>Title Here</title>
        <link href="http://somelink.com/link1&amp;amp;ref=rss" rel="alternate" />
        <link href="http://somelink.com/link2&amp;amp;ref=rss" rel="tag:somelink.com/apply_url"/>
    ...
    </entry>

i pull the atom feed like so,

// In controller index method
@rss = SimpleRSS.parse open('http://somelink.com/atom')

Then i output the response in the view, which i am writing using haml, as follows:

- @rss.entries.each do |item|
  .title-div
    = item.title
  .title-link
    = item.link //outputs the first link

I could run a second loop for the links but is there a way to get the second link without it? Like reading the "rel" attribute and outputting the correct link? How do i do this in haml/rails?

© Stack Overflow or respective owner

Related posts about ruby-on-rails

Related posts about haml