<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DZone Snippets: rss code</title>
    <link>http://snippets.dzone.com/posts</link>
    <pubDate>Tue, 14 Oct 2008 04:00:47 GMT</pubDate>
    <description>DZone Snippets: rss code</description>
    <item>
      <title>Atom rxml template</title>
      <link>http://snippets.dzone.com/posts/show/559</link>
      <description>This rxml template (modified from the one in blinksale.com) generates valid Atom 1.0 feeds. If you have a partial to create HTML for each item, they can be included in the feed's "content" elements.&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;xml.instruct!&lt;br /&gt;&lt;br /&gt;xml.feed "xmlns" =&gt; "http://www.w3.org/2005/Atom" do&lt;br /&gt;&lt;br /&gt;  xml.title   "Feed Name"&lt;br /&gt;  xml.link    "rel" =&gt; "self", "href" =&gt; url_for(:only_path =&gt; false, :controller =&gt; 'feeds', :action =&gt; 'atom')&lt;br /&gt;  xml.link    "rel" =&gt; "alternate", "href" =&gt; url_for(:only_path =&gt; false, :controller =&gt; 'posts')&lt;br /&gt;  xml.id      url_for(:only_path =&gt; false, :controller =&gt; 'posts')&lt;br /&gt;  xml.updated @posts.first.updated_at.strftime "%Y-%m-%dT%H:%M:%SZ" if @posts.any?&lt;br /&gt;  xml.author  { xml.name "Author Name" }&lt;br /&gt;&lt;br /&gt;  @posts.each do |post|&lt;br /&gt;    xml.entry do&lt;br /&gt;      xml.title   post.title&lt;br /&gt;      xml.link    "rel" =&gt; "alternate", "href" =&gt; url_for(:only_path =&gt; false, :controller =&gt; 'posts', :action =&gt; 'show', :id =&gt; post.id)&lt;br /&gt;      xml.id      url_for(:only_path =&gt; false, :controller =&gt; 'posts', :action =&gt; 'show', :id =&gt; post.id)&lt;br /&gt;      xml.updated post.updated_at.strftime "%Y-%m-%dT%H:%M:%SZ"&lt;br /&gt;      xml.author  { xml.name post.author.name }&lt;br /&gt;      xml.summary "Post summary"&lt;br /&gt;      xml.content "type" =&gt; "html" do&lt;br /&gt;        xml.text! render(:partial =&gt; "posts/post", :post =&gt; post)&lt;br /&gt;      end&lt;br /&gt;    end&lt;br /&gt;  end&lt;br /&gt;&lt;br /&gt;end&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Sat, 06 Aug 2005 02:53:28 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/559</guid>
      <author>sco (Scott Raymond)</author>
    </item>
    <item>
      <title>RSS2 rxml template</title>
      <link>http://snippets.dzone.com/posts/show/558</link>
      <description>Some of the rxml RSS 2 templates posted here will work, but have small validation problems. As far as I can tell, this one passes validation every time, given an instance variable @posts, with the appropriate methods. From the source of blinksale.com:&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;xml.instruct!&lt;br /&gt;&lt;br /&gt;xml.rss "version" =&gt; "2.0", "xmlns:dc" =&gt; "http://purl.org/dc/elements/1.1/" do&lt;br /&gt;  xml.channel do&lt;br /&gt;&lt;br /&gt;    xml.title       "Feed Name"&lt;br /&gt;    xml.link        url_for :only_path =&gt; false, :controller =&gt; 'posts'&lt;br /&gt;    xml.pubDate     CGI.rfc1123_date @posts.first.updated_at if @posts.any?&lt;br /&gt;    xml.description "Feed Description"&lt;br /&gt;&lt;br /&gt;    @posts.each do |posts|&lt;br /&gt;      xml.item do&lt;br /&gt;        xml.title       post.name&lt;br /&gt;        xml.link        url_for :only_path =&gt; false, :controller =&gt; 'posts', :action =&gt; 'show', :id =&gt; post.id&lt;br /&gt;        xml.description post.body&lt;br /&gt;        xml.pubDate     CGI.rfc1123_date post.updated_at&lt;br /&gt;        xml.guid        url_for :only_path =&gt; false, :controller =&gt; 'posts', :action =&gt; 'show', :id =&gt; post.id&lt;br /&gt;        xml.author      "#{post.author.email} (#{post.author.name})"&lt;br /&gt;      end&lt;br /&gt;    end&lt;br /&gt;&lt;br /&gt;  end&lt;br /&gt;end&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Sat, 06 Aug 2005 02:44:12 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/558</guid>
      <author>sco (Scott Raymond)</author>
    </item>
  </channel>
</rss>
