【发布时间】:2015-06-30 00:30:38
【问题描述】:
问:如何使用 Ruby/Rails 生成特定于 iTunes 的 XML 节点?
尝试生成 iTunes XML 提要,例如(基于example):
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
很高兴地产生了类似的东西:
<?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>
但看起来我需要生成特定于 iTunes 的 XML 节点(例如按照 Working With 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 ...
不确定如何生成 iTunes 特定节点,因为它们中有冒号。
标准 RSS 节点如下:
xml.item --> <item>
如何生成如下节点:
<rss xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd" version="2.0"><itunes:author>
【问题讨论】:
标签: ruby-on-rails xml rss itunes