Never been to DZone Snippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

RSS feed in .rxml template (See related posts)

xml.rss('version' => '2.0') do
  xml.channel do 
    xml.title(page_title)
    xml.link(@request.protocol + @request.host_with_port + url_for(:rss => nil))
    xml.description(page_title)
    @posts.each { |p|
      xml.item do 
        xml.title(p.title)
        xml.link(@request.protocol + @request.host_with_port + url_for(:controller => "posts", :action => "show", :id => p.id))
        xml.description(niceify_html_for_rss(p.content))
        xml.pubDate(p.updated_at)
      end
    }
  end
end

Comments on this post

beate posts on Sep 10, 2005 at 22:11
What is "niceify_html_for_rss"?
beate posts on Sep 10, 2005 at 22:16
And instead of
xml.pubDate(p.updated_at)

this would be better:
xml.pubDate(CGI.rfc1123_date p.updated_at)
rajeshb posts on Apr 17, 2006 at 06:25
What is "niceify_html_for_rss"?

peter posts on Apr 17, 2006 at 21:02
Oh, it's something that just knocks out the HTML, etc. In that case HTML wasn't required.
philipp13 posts on Jan 23, 2007 at 00:50
RSS expects dates formatted according to RFC 822, so instead of

xml.pubDate(p.updated_at)


use

xml.pubDate(p.updated.at.rfc822)

You need to create an account or log in to post comments to this site.


Click here to browse all 5147 code snippets

Related Posts