RSS Syntax

The syntax of RSS 2.0 is simple and strict. These rules are easy to learn and easy to use.

How RSS works

RSS is used to share information between websites.

Using RSS, you register your content with a company called an aggregator.

One of the steps is to create an RSS document and then save it with a .xml suffix. Upload this file to your website. Next, register with an RSS aggregator. Every day, the aggregator will search the registered websites for RSS documents, validate their links, and display information about the feeds, so customers can link to documents that interest them.

Tip:Please go to RSS publishing This section explores free RSS aggregator services.

An RSS instance document

RSS documents use a simple self-describing syntax:

Let's look at a simple RSS document:

<?xml version="1.0" encoding="ISO-8859-1" ?>
<rss version="2.0">
<channel>
  <title>CodeW3C.com Home Page</title>
  <link>http://www.codew3c.com</link>
  <description>Free web building tutorials</description>
  <item>
    <title>RSS Tutorial</title>
    <link>http://www.codew3c.com/rss</link>
    <description>New RSS tutorial on CodeW3C.com</description>
  </item>
  <item>
    <title>XML Tutorial</title>
    <link>http://www.codew3c.com/xml</link>
    <description>New XML tutorial on CodeW3C.com</description>
  </item>
</channel>
</rss>

The first line of the document: XML declaration - defines the XML version and character encoding used in the document. This example complies with the 1.0 specification and uses the ISO-8859-1 (Latin-1/West European) character set.

The next line is the RSS declaration that identifies this document as an RSS document (this example is RSS version 2.0).

The next line contains the <channel> element. This element is used to describe the RSS feed.

The <channel> element has three required child elements:

  • <title> - Defines the title of the channel. (such as CodeW3C Homepage)
  • <link> - Defines the hyperlink to the channel. (such as www.codew3c.com)
  • <description> - Describes this channel (such as free website building tutorials)

Each <channel> element can have one or more <item> elements.

Each <item> element can define an article or 'story' in an RSS feed.

The <item> element has three required child elements:

  • <title> - Defines the title of the project. (such as RSS Tutorial)
  • <link> - Defines the hyperlink to the project. (such as http://www.codew3c.com/rss)
  • <description> - Describes this project (such as CodeW3C's RSS tutorial)

Finally, the two lines after that close the <channel> and <rss> elements.

Comments in RSS

The syntax for writing comments in RSS is similar to that of HTML:

<!-- This is an RSS comment -->

RSS uses XML to write

Because RSS is also XML, remember:

  • All elements must have a closing tag
  • Elements are case-sensitive
  • Elements must be correctly nested
  • Attribute values must be quoted