Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Extending RSS format with more fields?

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?

like image 468
TruMan1 Avatar asked Aug 07 '11 14:08

TruMan1


People also ask

Is RSS and XML the same?

The important difference between these formats is that XML sitemaps describe the whole set of URLs within a site, while RSS/Atom feeds describe recent changes. This has important implications: XML sitemaps are usually large; RSS/Atom feeds are small, containing only the most recent updates to your site.

Are all RSS feeds in XML?

RSS is a Web content syndication format. Its name is an acronym for Really Simple Syndication. RSS is a dialect of XML. All RSS files must conform to the XML 1.0 specification, as published on the World Wide Web Consortium (W3C) website.

Can you have multiple RSS feeds?

RSS makes it easy to combine several feeds into one feed. Enter the URL address of each feed, one on each line, and then press Create. Combine up to 100 feeds with at least two or more unique sources.


2 Answers

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> 
like image 128
Dan Diplo Avatar answered Oct 11 '22 12:10

Dan Diplo


You can extend the RSS message with any elements that you want, and the way that the RSS readers distinguish the standard elements from extensions is that the extensions is in a namespace. That way a standard reader can easily read the standard elements and ignore the extensions.

http://cyber.law.harvard.edu/rss/rss.html#extendingRss:

A RSS feed may contain elements not described on this page, only if those elements are defined in a namespace.

like image 26
Guffa Avatar answered Oct 11 '22 13:10

Guffa