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

gsch's Answer:

Reply by gsch 911 days ago

Hi,

try this:

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 url_for :only_path => false, :controller => 'articles'
xml.description "Channel description"

@articles.each do |article|
xml.item do
xml.title article.title
xml.link url_for :only_path => false, :controller => 'articles', :action => 'show', :id => article.id
xml.description article.content
xml.guid url_for :only_path => false, :controller => 'articles', :action => 'show', :id => article.id
end
end

end
end

Reply by gsch 911 days ago

Whoops.. formatting problems



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 url_for :only_path => false, :controller => 'articles'
xml.description "Channel description"

@articles.each do |article|
xml.item do
xml.title article.title
xml.link url_for :only_path => false, :controller => 'articles', :action => 'show', :id => article.id
xml.description article.content
xml.guid url_for :only_path => false, :controller => 'articles', :action => 'show', :id => article.id
end
end

end
end