Domanda

Precisely... can multiple <content:encoded> elements exist inside an <item> in a valid feed?


Full Story: I am modding the markup of my blog's RSS feeds for Google Currents, and for the app to display image galleries in articles as slideshows, the markup of my feed should look like this:

<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>

But due to the way my WordPress blog works, the galleries are shown within the article (which is usual), which means, the same happens in the RSS feeds as well. But the <media:content> element cannot be a sub-element of <content:encoded>.

So, I am wondering if I can do it like this and it'd still be valid RSS feed:

<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>

As you can see, I'd basically be splitting the <content:encoded> element into two, to give way for the slideshow markup. So, there'll be two <content:encoded> elements inside an <item>. Is that okay?

È stato utile?

Soluzione

Having run my feed through W3C's Feed Validation Service, the answer seems to be "YES", multiple <content:encoded> elements can exist inside an <item> in a feed.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top