RSS Syntax
The syntax of RSS 2.0 is very simple and very 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 the .xml extension. Then upload this file to your website. Next, register with an RSS aggregator. Every day, the aggregator visits registered websites to search for RSS documents, verify their links, and display information about the feeds, so that customers can link to documents that interest them.
Tip: Please see the RSS Publishing section to browse free RSS aggregator services.
RSS Examples
RSS documents use a simple, self-describing syntax.
Let's look at a simple RSS document:
Runoob Tutorial首页
http://www.runoob.com
免费编程教程
-
RSS 教程
http://www.runoob.com/rss
Runoob Tutorial Rss 教程
-
XML 教程
http://www.runoob.com/xml
Runoob Tutorial XML 教程
The first line in the document: the 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 (which supports Chinese).
The next line is the RSS declaration identifying this document as an RSS document (in this case RSS version 2.0).
The next line contains the
-
- Defines the title of the channel. (For example, the Runoob Tutorial homepage) - - defines the hyperlink to the channel. (e.g. www.runoob.com)
- describes the channel (e.g. free programming tutorials)
Each
Each
-
- Defines the title of the item. (e.g. RSS Tutorial) - - defines the hyperlink to the item. (e.g. http://www.runoob.com/rss)
- describes the item (e.g. Runoob Tutorial Rss tutorial)
Finally, the next two lines close the
Comments in RSS
The syntax for writing comments in RSS is similar to that of HTML:
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