RSS Syntax


RSS 2.0 syntax is simple and strict.


How RSS Works

RSS is used to share information between websites.

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

One of the steps is to create an RSS document and save it with a .xml extension. Then upload the file to your website. Next, register it with an RSS aggregator. Every day, the aggregator searches the registered websites for RSS documents, verifies their links, and displays information about the feed, so customers can link to documents that interest them.

Tip:PleaseRSS Publishingbrowse free RSS aggregator services in this section.


RSS Examples

RSS documents use a simple self-describing syntax.

Let's look at a simple RSS document:

<?xml version="1.0" encoding="UTF-8" ?>
<rss version="2.0">

<channel>
  <title>Example首页</title>
  <link>http://www.example.com</link>
  <description>免费编程教程</description>
  <item>
    <title>RSS 教程</title>
    <link>http://www.example.com/rss</link>
    <description>Example Rss 教程</description>
  </item>
  <item>
    <title>XML 教程</title>
    <link>http://www.example.com/xml</link>
    <description>Example XML 教程</description>
  </item>
</channel>

</rss>

The first line in 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 UTF-8 character set (supports Chinese).

The next line is the RSS declaration that identifies this document as an RSS document (in this example, 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. (e.g., Example Homepage)
  • <link> - defines the hyperlink to the channel. (e.g., www.example.com)
  • <description> - describes the channel (e.g., Free Programming Tutorials)

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

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

The <item> element has three required child elements:

  • <title> - defines the title of the item. (e.g., RSS Tutorial)
  • <link> - defines the hyperlink to the item. (e.g., http://www.example.com/rss)
  • <description> - describes the item (e.g., Example RSS Tutorial)

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


Comments in RSS

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

<!-- 这是一个 RSS 注释 -->


RSS is Written Using XML

Because RSS is also XML, remember:

  • All elements must have closing tags.
  • Elements are case-sensitive.
  • Elements must be properly nested.
  • Attribute values must be quoted.
Other Extensions