Your Guide to RSS Feeds Print

  • 23525

To have the most efficient app possible (meaning that it updates automatically with no maintenance by you), you'll want to have RSS Feeds for as much content as possible.  

  • Examples of content that should have an rss feed (Audio or Video Podcasts, Vimeo or YouTube videos, blog posts, events calendar, & other articles based on streams.)

If you want to know if your RSS Feed works you'll want to make use of two RSS validators:

Here's an article from IBM explaning all about RSS. 

Article source: http://www.ibm.com/developerworks/xml/library/x-rss20/

 

What's new in RSS 2.0?

RSS 2.0 builds upon the RSS 0.91 spec. It's backwards compatible, so tools that work with RSS 2.0 should work with 0.91 feeds. The updated spec adds a few elements, such as <cloud> and <guid>.

It also reduces some restrictions. Previously, the <link> and <url> elements could only be http or ftp; now, any valid URI can be used. In RSS 0.91, each channel could only contain 15 items, and elements were limited in length; these limits have been removed. Larger values should still be used with caution, because they may cause problems with older applications.

The greatest change, though, is the ability to extend the format using namespaces. RSS 2.0 supports namespaces, a standardized approach to adding elements not found in the spec. Feeds can contain new elements if they are defined in a namespace.

 

Overview of RSS 2.0

RSS is a dialect of XML, and is used for syndicating Web content and metadata. RSS 0.91 is the most commonly used of several versions available. For new RSS feeds, it's better to use version 2.0 because it is the current spec and, as mentioned above, it's backward compatible with 0.91.

Dave Winer authored version 2.0 of the spec. He intentionally avoided changes to the specification that would make it more difficult to use, or that would break existing applications. Winer sums up his philosophy like this: "Keep it simple. That's the value of RSS. Anyone who can understand a little HTML can understand RSS. That's important!"

The spec is published under a Creative Commons license (see Resources). This means that you're free to copy and distribute the spec, make derivative works, and to use it freely in commercial work. An advisory board is responsible for updating the spec, advocating for it, and documenting it.

Form of an RSS file

An 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.

The channel

A channel typically has three elements that tell you 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. It is used in the ALT attribute of the HTML <image> tag when the channel is rendered in HTML.
  • <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>: en-us
  • <copyright>: Copyright 2003, James Lewin
  • <managingEditor>: dan@spam_me.com (Dan Deletekey)
  • <webMaster>: dan@spam_me.com (Dan Deletekey)
  • <pubDate>: Sat, 15 Nov 2003 0:00:01 GMT
  • <lastBuildDate>: Sat, 15 Nov 2003 0:00:01 GMT
  • <category>: ebusiness
  • <generator>: Your CMS 2.0
  • <docs>: http://blogs.law.harvard.edu/tech/rss
  • <cloud>: Allows processes to register with a "cloud" to be notified of updates to the channel, implementing a lightweight publish-subscribe protocol for RSS feeds.
  • <ttl>: Time to live, a number representing the number of minutes a feed can be cached before it should be refreshed.
  • <rating>: The PICS rating for the channel.
  • <textInput>: Defines input box that can be displayed with the channel.
  • <skipHours>: A hint for aggregators that tells them which hours can be skipped for updates.
  • <skipDays>: A hint for aggregators that tells them which days can be skipped for updates.

Items

Items are usually the most important part of a feed. Each item can be an entry on a weblog, a complete article, a movie review, a classified ad, or whatever you want to syndicate with your channel. While other elements within a channel may stay constant, items are likely to change frequently.

You can have as many items as you want. The previous spec had a limit of 15 items, and this is still a good upper limit if you want to ensure backwards compatibility.

Elements of news items

An item typically contains three elements:

  • <title>: This is the name of the item. In standards use, this is translated into a headline within HTML.
  • <link>: This is the URL of the item. The title is commonly used as a link, pointing to the URL contained within the <link>element.
  • <description>: This is usually a summary of or commentary on the URL that is pointed to in the link.

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>: E-mail address of the author.
  • <category>: Supports organizing entries.
  • <comments>: URL of a page for comments on the item.
  • <enclosure>: Supports media objects associated with the item.
  • <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 from. This can be useful when items are aggregated together.

Listing 1 is an example of an RSS 2.0 file. Notice that the channel is contained within <rss version="2.0">. This very basic example shows how items and images are contained within the channel. The elements shown are the most commonly used channel sub-elements.


Listing 1. A simple RSS 2.0 file

<?xml version="1.0"?>
<rss version="2.0">
    <channel>
    <title>The channel's name goes here</title>
    <link>http://www.urlofthechannel.com/</link>
    <description>This channel is an example channel for an article.
    </description>
    <language>en-us</language>
    <image>
      <title>The image title goes here</title>
      <url>http://www.urlofthechannel.com/images/logo.gif</url>
      <link>http://www.urlofthechannel.com/</link>
    </image>
    <item>
      <title>The Future of content</title>
      <link>http://www.itworld.com/nl/ecom_in_act/11122003/</link>
      <description> The issue of people distributing and reusing
      digital media is a problem for many businesses. It may also be
      a hidden opportunity. Just as open source licensing has opened
      up new possibilities in the world of technology, it promises to do
      the same in the area of creative content.</description>
    </item>
    <item>
      <title>Online Music Services - Better than free?</title>
      <link>http://www.itworld.com/nl/ecom_in_act/08202003/</link>
      <description>More people than ever are downloading music from 
      the Internet. Many use person-to-person file sharing programs like 
      Kazaa to share and download music in MP3 format, paying nothing. 
      This has made it difficult for companies to setup online music 
      businesses. How can companies compete against free?</description>
    </item>
  </channel>
</rss>

 

Speaking in tongues

Because of the popularity of RSS, many tools have emerged that allow you to work with the files in almost any environment:

  • Java technology: An RSS Utilities Package, available at Sun's site, supports the use of a Tag Library within JavaServer Pages. It also includes an RSS parser.
  • Perl: Several established Perl tools work with RSS. XML::RSS provides a framework for creating and maintaining RSS files. It supports converting between the more commonly used versions.
  • Python: RSS.py is a set of classes for working with RSS channels with Python.

In addition, many content management and weblog tools support RSS directly. Most weblog tools, including Movable Type, Blogger, and Radio Userland, support RSS. Several content management systems, including Zope and CityDesk, now support it.

 

Extending RSS

RSS 2.0 has many optional elements, including those that are needed for most channels. However, it supports extensibility so you can use elements that aren't in the spec. The RSS 2.0 spec does not spend much time defining how this will work, though. Extensibility is summed up like this: "A RSS feed may contain elements not described on this page, only if those elements are defined in a namespace."

This leaves a great deal to the imagination! Fortunately, the spec includes an example, and you can refer to a number of examples currently in use.

The basic idea is that you can add any tag you want -- however, it's very easy to add elements that have multiple meanings. People using your channel might not have any idea what a particular tag means. For example, if I wanted to use the <analog>tag in a channel, it would be unclear what it meant. Web gurus might think the tag referred to Analog, the popular Web log file analyzer. Science fiction fans might think the tag had something to do with Analog, the classic sci-fi magazine. Musicians might think that it referred to a popular type of synthesizer, biologists a type of organ, and electrical engineers a type of circuit. Vagueness makes it difficult to understand the meaning of a tag.

Because of this, RSS lets you add any tag you like, but requires that it be used with a namespace. This helps to clarify what that tag means.

Getting back to the <analog> example, I might want to create a set of tags relating to e-business, and have my <analog> tag be an "e-business" element. To do this, I could create an e-business namespace, and have <analog> be a tag in this namespace. To do this, I would add the following namespace entry:

xmlns:ebusiness="http://www.lewingroup.com/ebusinessChannel"

 

This creates a namespace named "ebusiness" and indicates that the documentation for this namespace is located on my site. To use the <analog> tag, I could use the format <ebusiness:analog>. This would distinguish it from other possible meanings of analog, like <sciencefiction:analog> or <synthesizers:analog>.

A more practical example of extensibility is found within the sample file that accompanies the RSS 2.0 spec:


Listing 2. Namespaces in the RSS 2.0 spec sample file

<?xml version="1.0"?>
<!-- RSS generated by Radio UserLand v8.0.5 on 9/30/2002; 4:00:00 AM Pacific -->
<rss version="2.0" xmlns:blogChannel="http://backend.userland.com/blogChannelModule">
  <channel>
    <title>Scripting News</title>
    <link>http://www.scripting.com/</link>
    <description>A weblog about scripting and stuff like that.</description>
    <language>en-us</language>
    <blogChannel:blogRoll>
      http://radio.weblogs.com/0001015/userland/scriptingNewsLeftLinks.opml
    </blogChannel:blogRoll>
      <item>
      <description>Joshua Allen: 
      <a href="http://www.netcrucible.com/blog/2002/09/29.html#a243">
      Who loves namespaces?</a></description>
      <pubDate>Sun, 29 Sep 2002 19:59:01 GMT</pubDate>
      <guid>
      http://scriptingnews.userland.com/backissues/2002/09/29#When:12:59:01PM
      </guid>
      </item>
  </channel>
</rss>

 

In this example, a namespace called blogChannel is defined. It points to documentation that explains the use of several new elements that are common to weblogs. One of these is <blogroll>. The documentation explains that a blogroll is a collection of links within a weblog that point to sites related to your weblog's content.

The <blogChannel:blogRoll> tag provides the information needed for users or software to know that blogRoll is an element defined in the blogChannel namespace, and where the documentation for this can be found.

Again, RSS 2.0 requires namespaces only for elements not included in the spec. All the basic tags are assumed to be within the RSS 2.0 namespace. This makes the format easy to use, since you don't need to know anything about namespaces unless you want to extend RSS.


Was this answer helpful?

« Back