Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles
(untagged)

About RSS

0.00/5 (No votes)
26 Apr 2005 3  
What is RSS and how it is used to retrieve information.

Introduction

Want more traffic? Searching for an easy way to distribute your news? You need an RSS news feed. Thousands of web sites today use RSS as a "what's new" mechanism to drive traffic their way. RSS provides an easy way to monitor fresh content. RSS feeds highlight new material so that you don't have to repeatedly check a site yourself for updates. A number of free and commercial RSS Readers that will download and display RSS feeds are available for download.

Here's a typical example of how RSS is used:

  • An author has some new content that he wants to publish on his web-site.
  • He creates an RSS channel for the content.
  • This channel includes items for web pages they want to promote.
  • This channel can be read by remote applications, and converted to headlines and links.
  • People see the links on various sites, click on them, and go to the original publisher's site.

It's simple. All you need is the content you want broadcast, and one RSS text file.

What is RSS?

RSS was first invented by Netscape. They wanted an XML format that would be easy for them to get news stories and information from other sites and have them automatically added to their site. RSS (Really Simple Syndication) is an XML-based format for distributing and aggregating Web content (such as news headlines). All RSS files must conform to the XML 1.0 specification, as published on the World Wide Web Consortium (W3C) web site. Using RSS, Web content providers can easily create and disseminate feeds of data that include, for example, news links, headlines, and summaries. A program known as an RSS reader can check RSS feeds on behalf of a user and display any updated articles that it finds. You might have seen the little XML icons inviting you to "syndicate this site", but what does that really mean? Once you have an RSS reader installed, copy the link from one of those XML buttons on the RSS feeds page and paste it into your chosen reader application. This reader application lets you keep track of latest updates, without opening the actual site.

Once you've created the RSS text file, register it at various aggregators, and watch the hits roll in. Any site can now grab and display your feed regularly, driving traffic your way. Update your RSS file, and all the external sites that subscribe to your feed will be automatically updated. RSS data can flow into other services like PDAs, cell phones, etc.. Regular newsletters can easily be automated with RSS.

Uses

While headline syndication is the most common use for RSS, it is also used for many other purposes. It is also used for ad listings, recipes, reviews, and for tracking the status of software packages. RSS feeds are used in the world of e-commerce as a way of delivering information. You can keep track of top books and latest additions.

Search engines can be used to find content in RSS format. With Google, for example, you can add "filetype:rss" to a search to find your search terms in .rss files.

Basics

Here are the basics of RSS (no matter what the version is):

  • It is XML. This means that it must be well-formed, include a prolog and DTD, and all elements must be closed.
  • The first element in the document is the <rss> element. This includes a mandatory version attribute.
  • The next element is the <channel> element. This is the main container for all RSS data.
  • The <title> element is the title, either of the entire site (if it's at the top) or of the current item (if it's within an <item>).
  • The <link> element indicates the URL of the Web page that corresponds to the RSS feed, or if it's within an <item>, the URL to that item.
  • The <description> element describes the RSS feed or the item.
  • The <item> element is the heart of RSS feed. It contains all the headlines (<title>), URLs (<link>) and descriptions that will be in your feed.

Using these basic elements, you can create an RSS feed of your site. But it could get very tedious to create that feed manually every time you update your site. The best way to create an RSS feed is to use a tool which creates the headlines, links and descriptions for you automatically.

RSS defines XML tags for sharing news. Each RSS text file contains both static information about your site, plus dynamic information about your new contents, all surrounded by matching start and end tags.

Every content is defined by an <item> tag, which contains a headline title, URL, and description. Here's an example:

<item>
    <title>My Articles</title>
    <link>www.MyCollection.com/articles</link>
    <description>list of Articles written by me.</description>
</item>

Structure of RSS file

The RSS file is made up of a <channel> element and its sub-elements. <channel> contains elements that represent metadata about the channel such as a <title>, <link>, and <description> - in addition to the channel content itself, in the form of items. Items typically make up the bulk of the channel, and contain content that changes frequently.

A channel typically has three elements that give you information about the channel itself:

    <title>: The name of the channel or feed.
    <link>: The URL of the Web site or site area associated with this channel.
    <description>: A brief explanation of what the channel is.

Many channel sub-elements are optional. The commonly-used <image> element contains three required sub-elements:

    <url>: The URL of a GIF, JPEG, or PNG image that represents the channel.
    <title>: Describes the image.  
    <link>: The URL of the site. 
    When the channel is rendered as HTML, the image can act as a link to the site.

<image> also has three optional sub-elements:

    <width>: Number indicating the width of the image in pixels. 
      The maximum value is 144 and the default value is 88.
    <height>: Number indicating the height of the image in pixels. 
      The maximum value is 400 and the default value is 31.
    <description>: Contains text that is included in the title attribute 
      of the link that's formed around the image when rendered.

In addition, many other optional channel elements can be used. Most of these are self-explanatory:

    <language>, <copyright>, <managingEditor>, 
    <webMaster>, <pubDate>, <lastBuildDate>, 
    <category>, <generator>, <docs>, 
    <ttl>:Time to live, a number representing the number of minutes a feed 
    can be cached before it should be refreshed.
    <rating>, <t;textInput>, <skipHours>, <skipDays>.

Items are usually the most important part of a feed. While other elements within a channel may stay constant, items are likely to change frequently....... You can have as many items as you want (previous specifications had a limit of 15 items).

An <item> typically contains three elements:

    <title>: This is the name of the item. List of Elements of Items   
    <link>: This is the URL of the item.
    <description>: Summary.

All elements are optional, but an item must contain either a <title> or a <description>.

Several other optional elements of items can be used:

    <author>, <category>, <comments>, <enclosure>,
    <guid>: A permanent link that is uniquely tied to the item,
    <pubDate>: When the item was published,
    <source>: The RSS channel that an item comes on.

Below is a very basic example showing how items and images are contained within the channel. The elements shown are the most commonly used channel sub-elements.

<rss version="2.0">
<channel>
<title>Cool Collections</title>
<link>www.123.com/</link>
<description>Channel Description</description>
<language>en-us</language>
<image>
    <title>Image title</title>
    <url>www.123.com/image1.gif</url>
    <link>www.123.com</link>br>

The sample application

The application allows to generate a sample RSS file with the basic information. This output file is stored on the running application directory. It can be verified in any web-browser. The number of items is limited to three in this application. It can be extended if required. Also more tags can be added through some modifications. The file generated can be made available to various RSS feeds which will result in direct availability of information to the users.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here