【问题标题】:In feeds, can multiple <content:encoded> elements exist inside an <item>?在提要中,一个 <item> 中是否可以存在多个 <content:encoded> 元素?
【发布时间】:2012-09-08 02:51:17
【问题描述】:

准确地说...一个有效的提要中的&lt;item&gt; 中是否可以存在多个&lt;content:encoded&gt; 元素?


全文:我正在为Google Currents 修改我博客的 RSS 提要的标记,并且为了让应用程序以幻灯片形式在文章中显示图片库,我的提要的标记应如下所示:

<rss version="2.0" ... xmlns:media="http://search.yahoo.com/mrss/">
...
<item>
    <title>Item One</title>
    <link>http://example.com/news/item-one</link>
    <description>
        <p>This is an example feed item</p>
    </description>
    ...
    <pubDate>Thu, 04 Aug 2011 19:41:00 GMT</pubDate>
    <guid>http://example.com/news/item-one</guid>
    <media:content height="84" type="image/jpeg" width="140" url="http://static.example.com/photo1.jpg">
        <media:description>Caption for Photo 1</media:description>
    </media:content>
    <media:content height="100" type="image/jpeg" width="200" url="http://static.example.com/photo2.jpg">
        <media:description>Caption for Photo 2</media:description>
    </media:content>
    <content:encoded><![CDATA[
        <p>All the content goes here.</p>
        <p>This is another line.</p>
    ]]></content:encoded>
    ...
</item>
...
</rss>

但由于我的 WordPress 博客的工作方式,画廊会显示在文章中(这很常见),这意味着 RSS 提要中也会发生同样的情况。但是&lt;media:content&gt;元素不能是&lt;content:encoded&gt;的子元素。

所以,我想知道我是否可以这样做并且它仍然是有效的 RSS 提要:

<rss version="2.0" ... xmlns:media="http://search.yahoo.com/mrss/">
...
<item>
    <title>Item One</title>
    <link>http://example.com/news/item-one</link>
    <description>
        <p>This is an example feed item</p>
    </description>
    ...
    <pubDate>Thu, 04 Aug 2011 19:41:00 GMT</pubDate>
    <guid>http://example.com/news/item-one</guid>

    <content:encoded><![CDATA[
        <p>All the content goes here.</p>
    ]]></content:encoded>

    <media:content height="84" type="image/jpeg" width="140" url="http://static.example.com/photo1.jpg">
        <media:description>Caption for Photo 1</media:description>
    </media:content>
    <media:content height="100" type="image/jpeg" width="200" url="http://static.example.com/photo2.jpg">
        <media:description>Caption for Photo 2</media:description>
    </media:content>

    <content:encoded><![CDATA[
        <p>This is another line.</p>
    ]]></content:encoded>

    ...
</item>
...
</rss>

如您所见,我基本上会将&lt;content:encoded&gt; 元素一分为二,为幻灯片标记让路。所以,&lt;item&gt; 中会有两个&lt;content:encoded&gt; 元素。可以吗?

【问题讨论】:

  • 您是否通过验证器运行它?

标签: rss feed markup rss2


【解决方案1】:

通过W3C's Feed Validation Service 运行我的提要后,答案似乎是“是”,提要中的&lt;item&gt; 中可以存在多个&lt;content:encoded&gt; 元素。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2015-08-08
    • 2015-10-17
    • 2017-12-21
    • 2019-03-13
    • 1970-01-01
    • 2013-11-03
    • 1970-01-01
    相关资源
    最近更新 更多