I have a website that I need to create an RSS feed for. Is there a standard format for adding custom fields to an RSS feed? I would like to add a "location" element to my RSS feeds for example. I have some partners that would like to consume the feeds and be able to use the custom fields specific to my website.
For the current RSS 2.0 format, these are the included fields available from the RSS 2.0 specifications:
<?xml version="1.0" encoding="UTF-8" ?>
<rss version="2.0">
<channel>
<title>RSS Example</title>
<description>This is an example of an RSS feed</description>
<link>http://www.domain.com/link.htm</link>
<lastBuildDate>Mon, 28 Aug 2006 11:12:55 -0400 </lastBuildDate>
<pubDate>Tue, 29 Aug 2006 09:00:00 -0400</pubDate>
<language>en-us</language>
<copyright>Copyright 2002, Spartanburg Herald-Journal</copyright>
<managingEditor>[email protected] (George Matesky)</managingEditor>
<webMaster>[email protected] (Betty Guernsey)</webMaster>
<category>Newspapers</category>
<generator>MightyInHouse Content System v2.3</generator>
<docs>http://blogs.law.harvard.edu/tech/rss</docs>
<image>
<title>Something</title>
<url>http://something.com/image.jpg</url>
<link>http://something.com</link>
<description>This is something</description>
</image>
<rating>(PICS-1.1 "http://www.classify.org/safesurf/" l r (SS~~000 1))</rating>
<item>
<title>Item Example</title>
<description>This is an example of an Item</description>
<link>http://www.domain.com/link.htm</link>
<guid> 1102345</guid>
<pubDate>Tue, 29 Aug 2006 09:00:00 -0400</pubDate>
<author>[email protected] (Lawyer Boyer)</author>
<category>Grateful Dead</category>
<comments>http://www.myblog.org/cgi-local/mt/mt-comments.cgi?entry_id=290</comments>
<enclosure url="http://www.scripting.com/mp3s/weatherReportSuite.mp3" length="12216320" type="audio/mpeg" />
<source url="http://www.tomalak.org/links2.xml">Tomalak's Realm</source>
</item>
</channel>
</rss>
What if I wanted to add more elements to make them available for partners so they can consume and parse them as they please? At the same time, I do not want to break RSS readers if they add my RSS feed to it. Any idea on the best way to handle this?
According to the RSS 2.0 Specification then:
"RSS originated in 1999, and has strived to be a simple, easy to understand format, with relatively modest goals. After it became a popular format, developers wanted to extend it using modules defined in namespaces, as specified by the W3C.
RSS 2.0 adds that capability, following a simple rule. A RSS feed may contain elements not described on this page, only if those elements are defined in a namespace."
Check out the article Extending RSS 2.0 With Namespaces which shows you how to do this. An example from the article shows the author adding some custom blog fields to their feed:
<rss version="2.0"
xmlns="http://backend.userland.com/rss2"
xmlns:blogChannel="http://backend.userland.com/blogChannelModule">
<channel>
<title>Scripting News</title>
<link>http://www.scripting.com/</link>
<blogChannel:blogRoll>http://radio.weblogs.com/ ... /file.opml</blogChannel:blogRoll>
<blogChannel:mySubscriptions>http://ra ... /file.opml</blogChannel:mySubscriptions>
<blogChannel:blink>http://inessential.com/</blogChannel:blink>
.
.
.
</channel>
</rss>