RSS - Version 2.0 Tags and Syntax



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.

XML Version Identifier

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.

Syntax

  • <?xml version="1.0"?> or
  • <?xml version="1.0" encoding="[ encoding code here ]"?>

Here is the list of RSS v2.0 Supported Encodings.

Required

Always and exact. Optional encoding attribute (default is UTF-8).

RSS Version Identifier

Syntax

<rss version="2.0">

Required

Always and exact.

Start Channel Tag

There should be one channel start tag in each RSS2.0 File.

Syntax

<channel>

Required

Required. Maximum 1 per RSS file.

Channel Title

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.

Syntax

<title>TutorialsPoint</title>

Required

Required.

Channel Description

A channel will have a description tag as described below:

Syntax

<description>Your source for tutorials, references and manuals!</description>

Required

Required.

Channel Title Link (URL)

This is the link to your home page and required for a channel.

Syntax

<link>http://www.tutorialspoint.com</link>

Required

Required.

Channel Language

This specifies the language of your channel (website).

Syntax

<language>[ language code here ]</language>

Here is the list of RSS v2.0 Supported Languages.

Required

Optional.

Channel Rating

For a complete detail on how to use the Channel Rating check Using PICS Ratingsdiscussed above.

Syntax

<rating>[ PICS rating here ]</rating>

Required

Optional.

Copyright Identifier

This tag is allowed in an RSS 2.0 file.

Syntax

<copyright>Copyright 2007, TutorialsPoint</copyright>

Required

Optional.

Publication Date

This tag is allowed in an RSS 2.0 file. The publication date for the content in the channel.

Syntax

<pubDate>Thu, 19 Jul 2007 07:00:00 GMT</pubDate>

Required

Optional.

Last Build Date

This tag is allowed in an RSS 2.0 file. The last time the content of the channel changed.

Syntax

<lastBuildDate>Thu, 19 Jul 2007 16:20:26 GMT </lastBuildDate>

Required

Optional.

Channel Category

Specify one or more categories that the channel belongs to.

Syntax

<category>Newspapers </category>

Required

Optional.

Channel docs

A URL that points to the documentation for the format used in the RSS file. It's probably a pointer to this page.

Syntax

<docs>http://tutorialspoint.com/rss </docs>

Required

Optional.

Channel cloud

Allows processes to register with a cloud to be notified of updates to the channel, implementing a lightweight publish-subscribe protocol for RSS Feeds.

Syntax

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

Required

Optional.

Channel ttl

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.

Syntax

<ttl>60</ttl>

Required

Optional.

Managing Editor

Email address for person responsible for editorial content.

Syntax

<managingEditor>mohtashim@tutorialspoint.com</managingEditor>

Required

Optional

Webmaster

Email address for person responsible for technical issues relating to channel.

Syntax

<webMaster>mohtashim@tutorialspoint.com</webMaster>

Required

Optional.

Start Skip Hours Tag

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.

Syntax

<skipHours>

Required

Optional.

Hour

If you are using skipHours tag then it is required to use this tag as well.

Syntax

<hour>7</hour>

Required

Required, if <skipHours>. Maximum 24 per <skipHours> element.

Max Length

Numeric Value: 0 - 23.

End Skip Hours

If you are using skipHours tag then it is required to use this tag as well.

Syntax

</skipHours>

Required

Required, if <skipHours>.

Start Skip Days Tag

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.

Syntax

<skipDays>

Required

Optional.

Day

If you are using skipDays tag then it is required to use this tag as well.

Syntax

<day>Monday</day>

Required

Required, if <skipDays>. Maximum 7 per <skipDays>. element.

Max Length

1-10 characters.

End Skip Days

If you are using skipDays tag then it is required to use this tag as well.

Syntax

</skipDays>

Required

Required, if <skipDays>.

Start Image Tag

You can have one image start tag inside a channel. Syntax is as follows:

Syntax

<image>

Required

Optional.

Image ALT Text

If you are using image tag then it is required to use this tag as well.

Syntax

<title>TutorialsPoint Logo</title>

Required

Required, if <image> tag is available.

Image Location (URL)

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.

Syntax

<url>http://www.tutorialspoint.com/images/to-logo.gif</url>

Required

Required, if <image> tag is available.

Image Link (URL)

If you are using image tag then it is required to use this tag as well.

Syntax

<link>http://www.tutorialspoint.com/</link>

Required

Optional, if <image> tag is available.

Image Width

If you are using image tag, then it is optional to use this tag as well.

Syntax

<width>[ numeric value here ]</width>

Required

Optional, if <image> tag is available.

Max Length

Numeric Value: 1-144 (Default is 88).

Image Height

If you are using image tag, then it is optional to use this tag as well.

Syntax

<height>[ numeric value here ]</height>

Required

Optional, if <image> tag is available.

Max Length

Numeric Value: 1-400 (Default is 31).

Image Description

If you are using image tag then it is optional to use this tag as well.

Syntax

<description>Articles, discussions, builds, and more...</description>

Required

Optional, if <image> tag is available.

End Image Tag

If you are using image tag, then it is required to use this tag as well.

Syntax

</image>

Required

Required, if <image> tag is available.

Start Item Tag

This is an optional tag and you can have any number of item tags with-in a channel tag.

Syntax

<item>

Required

Optional.

Item Title

The title of the item. It is optional to use this tag.

Syntax

<title>Learning RSS</title>

Required

Optional, but better to use if <title> tag is available.

Item Link (URL)

The URL of the item. It is optional to use this tag.

Syntax

<link>http://www.tutorialspoint.com/rss/index.htm</link>

Required

Optional, but better to use if <title> tag is available.

Item Description

The item synopsis. It is optional to use this tag.

Syntax

<description>RSS Tutorials Online. Read more about it in this discussion...</description>

Required

Optional, but better to use if <title> tag is available.

Item Author

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.

Syntax

<author>AmberYasin@hotmail.com</author>

Required

Optional, but better to use if <title> tag is available.

Item Category

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.

Syntax

<category>Grateful Dead</category>
<category domain="http://www.fool.com/cusips">Grateful Dead</category>

Required

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.

Item Comments

This is an optional sub-element of item. If present, it is the url of the comments page for the item.

Syntax

<comments>http://example.com/rss/comments</comments>

Required

Optional.

Item enclosure

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

Syntax

<enclosure url="http://www.tutorialspoint.com/mp3s/tutorial.mp3" length="12216320" type="audio/mpeg" />

Required

Optional.

Item guid

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

Syntax

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

Required

Optional.

Item Publication Date

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

Syntax

<pubDate>Sun, 22 July 2007 15:21:36 GMT</pubDate>

Required

Optional.

Item Source

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

Syntax

<source url="http://www.tomalak.org/links2.xml">Tomalak's Realm</source>

Required

Optional.

End Item Tag

If you are using title tag, then it is required to use this tag as well.

Syntax

</item>

Start Text Input Tag

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.

Syntax

<textInput>

Required

Optional. Maximum 1 per channel.

Text Input Title (Label of Submit Button)

If you are using textInput tag, then it is required to use this tag as well.

Syntax

<title>Send</title>

Required

Required, if <textInput> tag is available.

Text Input Description

If you are using textInput tag, then it is required to use this tag as well.

Syntax

<description>Comments about TutorialsPoint?</description>

Required

Required, if <textInput> tag is available.

Text Input Name

If you are using textInput tag, then it is required to use this tag as well.

Syntax

<name>[ value of name= attribute of input tag here ]</name>

Required

Required, if <textInput> tag is available.

Text Input Link

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.

Syntax

<link>http://www.tutorialspoint.com/cgi-bin/sampleonly.cgi</link>

Required

Required, if <textInput> tag is available.

End Text Input Tag

If you are using textInput tag then it is required to use this tag as well.

Syntax

<textInput>

Required

Required, if <textInput> tag is available.

End Channel Tag

One end channel is required for a channel start tag.

Syntax

</channel>

Required

Required.

End RSS Tag

This is closing tag for an RSS0.91 document.

Syntax

</rss>

Required

Required.

Using Special Characters and HTML Entities

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.

RSS version 2.0 Example Feed

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>

RSS 2.0 File Extension

A specific file-extension for an RSS 2.0 document is not required. Either .rdf or .xml is recommended, the former being preferred.

rss-feed-formats.htm
Advertisements