No one was able to answer Rich Collins's question:

I am having trouble with the title attribute on an RSS feed generated with Rails:



xml.instruct!(
:xml, :version=>"1.0", :encoding => "utf-8"
)

xml.rss(
"version" => "2.0",
"xmlns:dc" => "http://purl.org/dc/elements/1.1/"
) do
xml.channel do
xml.title("Channel Title")
xml.link("http://the.channel.com/")
xml.description("Channel Description")
xml.pubDate(Time.now.strftime("%a, %d %b %Y %H:%M:%S %z"))
xml.item do
xml.title("Item Title")
xml.link("http://the.item.com/")
xml.description("Item Description")
xml.pubDate(Time.now.strftime("%a, %d %b %Y %H:%M:%S %z"))
end
end
end


The xml.title does not result in a title tag being written to the reponse for either call!

People succeed in answering Rich Collins's questions 37% of the time (32 successes in 86 attempts).

Answers by: gsch | Fear of Fish

Fear of Fish's Answer:

Reply by Fear of Fish 870 days ago

Try this out:

xml.instruct!
xml.rss "version" => "2.0", "xmlns:dc" => "http://purl.org/dc/elements/1.1/" do
xml.channel do
xml.title 'Channel Title'
xml.link 'http://the.channel.com/'
xml.pubDate CGI.rfc1123_date(Time.now)
xml.description 'Channel Description'
@posts.each do |post|
xml.item do
xml.title post.title
xml.link url_for( :only_path => false,
:controller => 'blog',
:action => 'article',
:id => post.id)
xml.description post.short_body.to_s
xml.pubDate CGI.rfc1123_date(post.created_at)
xml.guid url_for( :only_path => false,
:controller => 'blog',
:action => 'article',
:id => post)
end
end
end
end

I hope formatting comes out okay...bits need to be changed for you, but this is the format I use.

Reply by Rich Collins 869 days ago

Why would this fix the title issue?

I did fix it btw, but it is a hack:

xml << "" <br />xml.text! "The Title" <br />xml << ""

I will still pay the reward if I you can tell me why xml.title isn't working.

Reply by Fear of Fish 869 days ago

Did you try it out? If not what rails version you on?

Reply by Rich Collins 864 days ago

This did not work (I removed the posts so I didn't have to set them up). Channel Title is not written to the response

xml.instruct!
xml.rss "version" => "2.0", "xmlns:dc" => "http://purl.org/dc/elements/1.1/" do
xml.channel do
xml.title 'Channel Title'
xml.link 'http://the.channel.com/'
xml.pubDate CGI.rfc1123_date(Time.now)
xml.description 'Channel Description'
end
end

Chat Conversation 862 days ago

hey sorry just testing something Rich Collins at 8:49 PM on Wednesday July 12th, 2006