[英]Generating iTunes XML nodes in RSS feed using Ruby/Rails
Q: How do I generate the XML nodes specific to iTunes using Ruby/Rails? 问:如何使用Ruby / Rails生成特定于iTunes的XML节点?
Trying to generate iTunes XML feed, eg (based off example ): 尝试生成iTunes XML feed,例如(基于示例 ):
xml.instruct! :xml, :version => "1.0"
xml.rss(:version => "2.0") do
xml.channel do
xml.title "Your Blog Title"
xml.description "A blog about software and chocolate"
xml.link posts_url
@posts.each do |post|
xml.item do
xml.title post.title
xml.description "Temporary post description"
xml.pubDate post.created_at.to_s(:rfc822)
xml.link post_url(post)
xml.guid post_url(post)
end
end
end
end
Which happily generates something like: 会愉快地生成如下内容:
<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
<channel>
<title>Your Blog Title</title>
<description>A blog about software and chocolate</description>
<link>https://pubweb-thedanielmay.c9.io/sermons</link>
<item>
... omitted ...
</item>
</channel>
</rss>
But looks like I need to generate iTunes-specific XML nodes (as per Working With iTunes , eg) 但看起来我需要生成特定于iTunes的XML节点(例如,根据“使用iTunes” )
<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd" version="2.0"> <-- *
<channel>
<title>Your Blog Title </title>
... omitted ...
<itunes:subtitle>A program about everything</itunes:subtitle> <-- *
... etc ...
Not sure how I generate the iTunes-specific nodes as they have colons in them. 不知道如何生成iTunes特定节点,因为它们中带有冒号。
Standard RSS nodes are like: 标准RSS节点如下:
xml.item --> <item>
How do I get to generating nodes like: 我如何生成像这样的节点:
<rss xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd" version="2.0">
<itunes:author>
Ah, answers as per code via Ryan Bates' awesome Railscasts RSS sample 嗯,通过Ryan Bates出色的Railscasts RSS示例按代码回答
xml.rss "xmlns:itunes" => "http://www.itunes.com/dtds/podcast-1.0.dtd", :version => "2.0"
and 和
xml.itunes :author, author
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.