Here is the structure of an RSS 2.0 document:
<?xml version="1.0"?> <rss version="2.0"> <channel> <title>...</title> <link>...</link> <description>...</description> <language>...</language> <rating>...</rating> <copyright>...</copyright> <pubDate>...</pubDate> <lastBuildDate>...</lastBuildDate> <generator>....</generator> <docs>...</docs> <cloud>...</cloud> <ttl>...</ttl> <managingEditor>...</managingEditor> <webMaster>...</webMaster> <skipHours> <hour>...</hour> </skipHours> <skipDays> <day>...</day> </skipDays> <image> <title>...</title> <url>...</url> <link>...</link> <width>...</width> <height>...</height> <description>...</description> </image> <item> <title>...</title> <link>...</link> <description>...</description> <author>....</author> <category>....</category> <comments>....</comments> <enclosure ..../> <guid>....</guid> <pubDate>....</pubDate> <source>....</source> </item> ......More item tags..... <textInput> <title>...</title> <description>...</description> <name>...</name> <link>...</link> </textInput> </channel> </rss>
Here is the detail of all the optional and mandatory tags related to RSS 2.0. Check out the given example to prepare an RSS v2.0 Feed for your website.
NOTE: All the tags are case sensitive and should be used carefully.
As an XML application, an RSS document is not required to begin with an XML declaration. It should start with an XML version identifier tag.
Here is the list of RSS v2.0 Supported Encodings.
Always and exact. Optional encoding attribute (default is UTF-8).
<rss version="2.0">
Always and exact.
There should be one channel start tag in each RSS2.0 File.
<channel>
Required. Maximum 1 per RSS file.
The name of the channel. It's how people refer to your service. If you have an HTML website that contains the same information as your RSS file, the title of your channel should be the same as the title of your website.
<title>TutorialsPoint</title>
Required.
A channel will have a description tag as described below:
<description>Your source for tutorials, references and manuals!</description>
Required.
This is the link to your home page and required for a channel.
<link>http://www.tutorialspoint.com</link>
Required.
This specifies the language of your channel (website).
<language>[ language code here ]</language>
Here is the list of RSS v2.0 Supported Languages.
Optional.
For a complete detail on how to use the Channel Rating check Using PICS Ratingsdiscussed above.
<rating>[ PICS rating here ]</rating>
Optional.
This tag is allowed in an RSS 2.0 file.
<copyright>Copyright 2007, TutorialsPoint</copyright>
Optional.
This tag is allowed in an RSS 2.0 file. The publication date for the content in the channel.
<pubDate>Thu, 19 Jul 2007 07:00:00 GMT</pubDate>
Optional.
This tag is allowed in an RSS 2.0 file. The last time the content of the channel changed.
<lastBuildDate>Thu, 19 Jul 2007 16:20:26 GMT </lastBuildDate>
Optional.
Specify one or more categories that the channel belongs to.
<category>Newspapers </category>
Optional.
A URL that points to the documentation for the format used in the RSS file. It's probably a pointer to this page.
<docs>http://tutorialspoint.com/rss </docs>
Optional.
Allows processes to register with a cloud to be notified of updates to the channel, implementing a lightweight publish-subscribe protocol for RSS Feeds.
<cloud> domain="rpc.sys.com" port="80" path="/RPC2" registerProcedure="myCloud.rssPleaseNotify" protocol="xml-rpc" </cloud>
In this example, to request notification on the channel it appears in, you would send an XML-RPC message to rpc.sys.com on port 80, with a path of /RPC2. The procedure to call is myCloud.rssPleaseNotify.
Optional.
ttl stands for time to live. It is the number of minutes that indicates how long a channel can be cached before refreshing from the source.
<ttl>60</ttl>
Optional.
Email address for person responsible for editorial content.
<managingEditor>mohtashim@tutorialspoint.com</managingEditor>
Optional
Email address for person responsible for technical issues relating to channel.
<webMaster>mohtashim@tutorialspoint.com</webMaster>
Optional.
A list of <hour>s indicating the hours in the day, GMT, when the channel is unlikely to be updated. If this sub-item is omitted, the channel is assumed to be updated hourly.
<skipHours>
Optional.
If you are using skipHours tag then it is required to use this tag as well.
<hour>7</hour>
Required, if <skipHours>. Maximum 24 per <skipHours> element.
Numeric Value: 0 - 23.
If you are using skipHours tag then it is required to use this tag as well.
</skipHours>
Required, if <skipHours>.
A list of <day>s of the week, in English, indicating the days of the week when your channel will not be updated. As with activeHours, if you know your channel will never be updated on Saturday or Sunday, for example.
<skipDays>
Optional.
If you are using skipDays tag then it is required to use this tag as well.
<day>Monday</day>
Required, if <skipDays>. Maximum 7 per <skipDays>. element.
1-10 characters.
If you are using skipDays tag then it is required to use this tag as well.
</skipDays>
Required, if <skipDays>.
You can have one image start tag inside a channel. Syntax is as follows:
<image>
Optional.
If you are using image tag then it is required to use this tag as well.
<title>TutorialsPoint Logo</title>
Required, if <image> tag is available.
Location to load a resource from. Note that this is slightly different from the link tag, which specifies where a user should be re-directed to if a resource is selected.
<url>http://www.tutorialspoint.com/images/to-logo.gif</url>
Required, if <image> tag is available.
If you are using image tag then it is required to use this tag as well.
<link>http://www.tutorialspoint.com/</link>
Optional, if <image> tag is available.
If you are using image tag, then it is optional to use this tag as well.
<width>[ numeric value here ]</width>
Optional, if <image> tag is available.
Numeric Value: 1-144 (Default is 88).
If you are using image tag, then it is optional to use this tag as well.
<height>[ numeric value here ]</height>
Optional, if <image> tag is available.
Numeric Value: 1-400 (Default is 31).
If you are using image tag then it is optional to use this tag as well.
<description>Articles, discussions, builds, and more...</description>
Optional, if <image> tag is available.
If you are using image tag, then it is required to use this tag as well.
</image>
Required, if <image> tag is available.
This is an optional tag and you can have any number of item tags with-in a channel tag.
<item>
Optional.
The title of the item. It is optional to use this tag.
<title>Learning RSS</title>
Optional, but better to use if <title> tag is available.
The URL of the item. It is optional to use this tag.
<link>http://www.tutorialspoint.com/rss/index.htm</link>
Optional, but better to use if <title> tag is available.
The item synopsis. It is optional to use this tag.
<description>RSS Tutorials Online. Read more about it in this discussion...</description>
Optional, but better to use if <title> tag is available.
It's the email address of the author of the item. If you are using title tag then it is optional to use this tag.
<author>AmberYasin@hotmail.com</author>
Optional, but better to use if <title> tag is available.
Includes the item in one or more categories. This is an optional sub-element of item.
It has one optional attribute, domain, and a string that identifies a categorization taxonomy.
<category>Grateful Dead</category> <category domain="http://www.fool.com/cusips">Grateful Dead</category>
Optional, you may include as many category elements as you need to, for different domains, and to have an item cross-referenced in different parts of the same domain.
This is an optional sub-element of item. If present, it is the url of the comments page for the item.
<comments>http://example.com/rss/comments</comments>
Optional.
<enclosure> is an optional sub-element of item. It has three required attributes. url says where the enclosure is located, length says how big it is in bytes, and type says what its type is, a standard MIME type.
<enclosure url="http://www.tutorialspoint.com/mp3s/tutorial.mp3" length="12216320" type="audio/mpeg" />
Optional.
<guid> is an optional sub-element of item. The guid stands for globally unique identifier. It's a string that uniquely identifies the item. When present, an aggregator may choose to use this string to determine if an item is new.
<guid>http://some.server.com/weblogItem3207</pubDate>
There are no rules for the syntax of a guid. Aggregators must view them as a string. It's up to the source of the Feed to establish the uniqueness of the string.
Optional.
<pubDate> is an optional sub-element of item. Its value is a date, indicating when the item was published. If it's a date in the future, aggregators may choose not to display the item until that date.
<pubDate>Sun, 22 July 2007 15:21:36 GMT</pubDate>
Optional.
<source> is an optional sub-element of item. Its value is the name of the RSS channel that the item came from, derived from its <title>. It has one required attribute, url, which links to the XMLization of the source.
The purpose of this element is to propagate credit for links, to publicize the sources of news items. It can be used in the Post command of an aggregator. It should be generated automatically when forwarding an item from an aggregator to a weblog authoring tool.
<source url="http://www.tomalak.org/links2.xml">Tomalak's Realm</source>
Optional.
If you are using title tag, then it is required to use this tag as well.
</item>
A channel may optionally contain a <textInput> sub-element, which contains four required sub-elements.
The purpose of the <textInput> element is something of a mystery. You can use it to specify a search engine box. Or to allow a reader to provide feedback. Most aggregators ignore it.
<textInput>
Optional. Maximum 1 per channel.
If you are using textInput tag, then it is required to use this tag as well.
<title>Send</title>
Required, if <textInput> tag is available.
If you are using textInput tag, then it is required to use this tag as well.
<description>Comments about TutorialsPoint?</description>
Required, if <textInput> tag is available.
If you are using textInput tag, then it is required to use this tag as well.
<name>[ value of name= attribute of input tag here ]</name>
Required, if <textInput> tag is available.
This is the link to the script, which will process passed data. If you are using textInput tag then it is required to use this tag as well.
<link>http://www.tutorialspoint.com/cgi-bin/sampleonly.cgi</link>
Required, if <textInput> tag is available.
If you are using textInput tag then it is required to use this tag as well.
<textInput>
Required, if <textInput> tag is available.
One end channel is required for a channel start tag.
</channel>
Required.
This is closing tag for an RSS0.91 document.
</rss>
Required.
Although an RSS 2.0 file is an XML document, RSS 2.0 extends XML by supporting a full set of HTML entities. If you want to use special characters such as ampersands (&) in <url> or <link> tags, you must substitute the appropriate decimal or HTML entities for those characters.
Check for a complete set of HTML entitiesin our HTML tutorial.
The following example shows how to write RSS Feed using version 2.0.
<?xml version="1.0"?> <rss version="2.0"> <channel> <title>TutorialsPoint</title> <link>http://www.tutorialspoint.com</link> <description>Tutorials and Reference Manuals</description> <language>en-us</language> <pubDate>Fri, 30 May 2003 11:06:42 GMT</pubDate> <lastBuildDate>Fri, 30 May 2003 11:06:42 GMT</lastBuildDate> <docs>http://www.tutorialspoint.com/rss</docs> <generator>Weblog Editor 2.0</generator> <managingEditor>mohtashim@tutorialspoint.com</managingEditor> <webMaster>webmaster@tutorialspoint.com</webMaster> <item> <title>RSS Tutorial</title> <link>http://www.tutorialspoint.com/rss</link> <description>Learn RSS in simple steps</description> <pubDate>Fri, 30 May 2003 11:06:42 GMT</pubDate> <guid> http://www.tutorialspoint.com/rss/rss-feed-formats.htm#v0.91 </guid> </item> <item> <description>RSS Feed Formats</description> <pubDate>Fri, 30 May 2003 11:06:42 GMT</pubDate> <guid> http://www.tutorialspoint.com/rss/rss-feed-formats.htm#v2.0 </guid> </item> </channel> </rss>
A specific file-extension for an RSS 2.0 document is not required. Either .rdf or .xml is recommended, the former being preferred.