<?xml version="1.0" encoding="UTF-8"?>
<post>
  <body>Controller:
&lt;code&gt;
  def sitemap 
    @posts = Post.find :all, :conditions =&gt; {:private =&gt; false}
    respond_to do |format|
      format.xml  { render :layout =&gt; false }
    end    
  end
&lt;/code&gt;
Helper:
&lt;code&gt;
  def w3c_date(date)
    date.utc.strftime("%Y-%m-%dT%H:%M:%S+00:00")
  end
&lt;/code&gt;
View: sitemap.xml.builder
&lt;code&gt;
xml.instruct!

xml.urlset 
  "xmlns" =&gt; "http://www.sitemaps.org/schemas/sitemap/0.9",
  "xsi:schemaLocation"=&gt;"http://www.sitemaps.org/schemas/sitemap/0.9
  http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd", 
  "xmlns"=&gt;"http://www.sitemaps.org/schemas/sitemap/0.9" do
  xml.url do
    xml.loc         "http://www.sharesnippets.com"
    xml.lastmod     w3c_date(Time.now)
    xml.changefreq  "always"
  end

  @posts.each do |post|
    xml.url do
      xml.loc         url_for(:only_path =&gt; false, :controller =&gt; 'post', :action =&gt; 'show', :id =&gt; post.id)
      xml.lastmod     w3c_date(post.created_at)
      xml.changefreq  "weekly"
      xml.priority    "0.9"
    end
  end
end
&lt;/code&gt;

route:
&lt;code&gt;
  map.connect "sitemap.xml", :controller =&gt; "home", :action =&gt; "sitemap"  

&lt;/code&gt;</body>
  <created-at type="datetime">2009-04-01T01:57:14+03:00</created-at>
  <id type="integer">3</id>
  <permalink>rails-sitemap-generator</permalink>
  <private type="boolean">false</private>
  <title>Rails sitemap generator</title>
  <updated-at type="datetime">2009-04-01T02:09:05+03:00</updated-at>
  <user-id type="integer">2</user-id>
</post>
