Sevencolors studies:
experiments with Javascript, CSS, PHP and web standards

Printer icon

RSS feed

How to write and use an RSS feed

About RSS

RSS is an XML document. Is a way for web sites to render easily accessible a short text summary of an article that links to its full version. An RSS file (also known as an RSS feed or RSS channel) consists of a list of items, each of which contains a title, description and a link to a web page. RSS files are written in XML and are a mini database containing headlines and descriptions of what's new on a site. Used by many news media (New York Times, BBC, Reuters) RSS is a very simple, very useful font of information also for any other kind of online activity. With a standards compliant RSS Feed reader is possible to read the file to find out about new entries. Included in the file there are also other informations, as a published date, a category and the author, for example, but they are optional.

The code

<?xml version="1.0" encoding="ISO-8859-1"?>
<rss version="2.0">
<title> TITLE </title>
<link> LINK TO PAGE </link>
<description> DESCRIPTION OF SITE </description>
<title> ARTICLE TITLE </title>
<link> LINK TO ARTICLE </link>
<description> SHORT TEXT DESCRIPTION </description>

The tags used in the above RSS file are the minimum required.

The tags:

  1. <rss version="2.0"></rss>RSS opening tag and version
  2. <channel>opening tag for main "container"
  3. <title></title>the title of your site
  4. <link></link>link to your index page
  5. <description></description>description of the site

Those above are the minimum required tags in the first part of the RSS file. There are also other tags as <language></language>, <lastBuildDate></lastBuildDate> and <webMaster></webMaster> for example, but they are optional. Always remember to close tags.

Each article must be in between <item></item> tags:

  1. <item>opening item tag
  2. <title></title>the article`s title
  3. <link></link>link to the page the article is on
  4. <description></description>article`s description
  5. </item>closing item tag

Just keep adding articles enclosed between <item></item> tags with their informations.

Close it all up:

  1. </channel>closing main "container" tag
  2. </rss>closing RSS tag

Last instructions:

For all tags and their meaning refer to RSS 2.0 specification. You could just copy the file above, paste it into the web editor of your choice and save it as "your_file.xml", where "your_file" is whatever name you want to give to the file. Fill it in with your datas, save it together with all the other files of your site (or in a specific RSS folder, it does not matter), publish it and make it accessible by adding a link (usually on your site index page) that points to it and a <link rel="alternate" type="application/rss+xml" title="RSS" href="your_file.xml" /> in the <head> of the same page. Whenever you add a new article to your site, you have to rewrite and republish the RSS accordingly to keep it updated. It`s best to keep the entries (<item></item>) number to a maximum of ten. Add the new article datas on top and delete the oldest one.

Why RSS:

People interested in the content of your web site may include your RSS file address in their feeds list and always know when something new gets added to your site.

Here is a list of RSS feed readers to download:

A few related links:

There is another way to syndicate web site content: