RSS was originally created in 1999 by Netscape as a channel description framework for their My Netscape Network. MNN was a portal system that allowed end users to selectively view new content from their choice of content providers. RSS was created as a means of gathering that content. Since its creation, RSS has been updated and expanded to handle a much wider range of content with a far broader range of uses.
Simply put RSS is an XML application for simple web feed syndication and content subscriptions. Okay, maybe that’s not so simple. Let’s say you have content on your site that you want to feed, or make available for other sites. This is known as web syndication. Most commonly this takes the form of sharing news headlines, product releases, or some similar timely content. RSS provides a standardized method for web sites to use when creating these feeds.
Based on XML, RSS 2.0 allows you to take bits of content or information and place them into a simple text file. Other web sites or reader programs, also known as news aggregators or news readers, read this text file at a specified interval. If new content is found, the listing is updated and the new content is shown to the end user. Through the use of third party programs, browser plug-ins, or web applications users can effectively subscribe to your content; thus coining the term content subscription.
RSS is a very effective and popular way to broadcast your content. Many newer technologies have emerged based on the idea of RSS; not the least of which is Podcasting, a method of broadcasting media content from your website to mobile users for viewing with iPods or similar handheld devices.
The current version RSS 2.0 was created to improve upon version 0.93 which was RDF based. This version has high modularity and is designed to be much more simple to implement. RSS 2.0 is highly supported by every popular browser and news aggregators. Support for XML based RSS has even been built into many common web languages such as ASP, JSP, and PHP.
Sharing your content
The first step in setting up web syndication with RSS 2.0 is obviously to decide what content to share. You can share whole pages, articles, excerpts, or headlines from your web site. You can also share media files such as movies, audio clips, and images. Virtually any type of content can be shared. And you control how that sharing is done.
You can feed the actual content, like a movie, or merely send a headline from your website and provide a link back. It all depends on your specific needs and how much of your content you want to provide. Keep in mind that even if you offer your content via RSS, you still retain the original copyright.
You’ll need to decide how you want to arrange your content. You can provide titles, descriptions, and links (among other things) for your content. So figure out an intelligent way to group it so that it makes the most sense to your readers. Remember, they aren’t going to see your whole site, just what you provide—so everything should be as descriptive as possible.
Remember to include as many keywords as possible too. Search engines will index your RSS feeds so they can help improve search engine ranking when used effectively. Google Sitemaps even allows you to submit an RSS feed now. This is especially convenient for blogging sites and forums.
Once you’ve decided on what content to share and how you would like to present it, all you need is a simple text editor. Any basic text editor like Notepad will do. I, myself, prefer to use a text editor such as Notepad++ that features context highlighting support for XML. Since XML syntax is very strict, this makes it much easier to avoid small mistakes.
The next step is to learn the RSS 2.0 XML namespace. There are a number of predefined elements for you to use. Some are required, many are optional. The more you can provide the better off you’ll be, but we’ll go in to that in more detail later.
The XML:RSS 2.0 namespace
Let’s begin with the basics. You’ll start your RSS feed by setting up an XML document.
<?xml version="1.0" ?>
<rss version="2.0">
<channel>
The opening tag establishes our file as an XML document. The next tag tells the XML parser that we are using the RSS 2.0 namespace. This allows us to use “short” tag names to reference our elements. Finally, we use the channel element to indicate the start of our RSS channel feed.
Next we want to identify what our channel will hold. In this example, I’m going to build an RSS feed for all of my articles published on the Developer Shed network of sites. So I’ll add this next piece of code.
<title>Popular Articles by Nilpo</title>
<description>Popular articles by Nilpo published by Developer Shed.</description>
<link>http://www.nilpo.com</link>
<language>en-us</language>
The first three elements are required. The title element defines the name of your channel. In most cases this is just the name of your web site. The description provides a brief overview of the channels contents. The link element is used to provide a valid URI to the html website that the channel corresponds to. I’ve also included the language element. This element optionally defines the language that the channel is written in. Valid values for this element must be RFC 1766 compliant.
Now that we’ve established a channel, we can begin adding content. The RSS 2.0 namespace provides the item element for this. Take a look at the following code segment.
<item>
<title>A New Toolbar Can Boost Your Web Site Traffic Dramatically</title>
<description>Dev Articles - Embedded Tools - 1/10/07</description>
<link>http://www.devarticles.com/c/a/Embedded-Tools/A-New-Toolbar-Can-Boost-Your-Web-Site-Traffic-Dramatically</link>
</item>
Here we’ve defined at item for our channel. Three basic elements are required: title, description, and link. Title defines the title for our item. This should be a descriptive name for the content that it holds. In my case, the name of the article is appropriate. The description should describe the content. I could have given and overview or an introduction to the articles, but instead I chose to add the site information and publication date. Finally, the link element should provide the URL to the content itself.
You would add subsequent items in the same way. Each item should be enclosed it its own item element.
</channel>
</rss>
We end our RSS channel by closing the channel and rss tags. This is a basic RSS feed although at this point it’s still formed pretty poorly. Many news readers would have a hard time updating this feed properly because we haven’t provided any information to differentiate between existing items and newly added ones.
Expanding the channel
There are a number of optional elements that you can use to add the effectiveness of your channel. These elements are used to provided additional, more specific information about your content.
There are additional elements at both the channel level and the item level. The additional channel elements are used to improve indexing and to provide additional information about your channel to your readers. The additional item elements are used to provide additional information about your content and to help ensure that your feed updates properly in news readers.
We’ll begin with the additional channel elements. You may or may not need to use all of these. The rule of thumb is to add as many as you can so that your feed contains as much information as you are able to provide. The following table lists all of the additional channel elements.
|
Element |
Description |
|
copyright |
The copyright notice for your channel. |
|
managingEditor |
The email address for the person responsible for the item content. |
|
webmaster |
The email address of your contents technical contact. |
|
pubDate |
The publication date of your content. |
|
lastBuildDate |
The last time the channel feed was updated. |
|
category |
Used to specify categories that your channel belongs in. Valid values will be provided by the listing service or the site that your feed will appear on. |
|
generator |
A string that indicates the program that generated the channel. |
|
docs |
A URL pointing to the documentation for the RSS specs that were used to build this channel. (For reference purposes) For RSS 2.0 this will always be: http://blogs.law.harvard.edu/tech/rss |
|
cloud |
Used to provide information for the rssCloud interface. |
|
ttl |
Time To Live – indicates how many minutes a channel can be cached before the news reader refreshes it from the source. |
|
image |
A gif, jpg, or png that can be displayed as your channels thumbnail. |
|
rating |
The channel’s PICS rating. |
|
textInput |
Used to provide a text box for user input however support for this element is extremely limited. |
|
skipHours |
A value between 0 and 23 that tells news readers when not to update your channel. |
|
skipDays |
A value containing a day of the week that tells news readers when not to update your channel. |
Again, you will not use most of these elements. I’ll show you only the ones that relate to my channel. For complete documentation, you can visit the RSS 2.0 Specification on the Harvard Technology site.
My updated channel portion looks like the following:
<title>Popular Articles by Nilpo</title>
<description>Popular articles by Nilpo published by Developer Shed.</description>
<link>http://www.nilpo.com</link>
<language>en-us</language>
<copyright>Copyright © 2006,2007 Developer Shed, Inc.</copyright>
<managingEditor>contacteditor@developershed.com</managingEditor>
<pubDate>Sat, 13 Jan 2007 00:00:01 GMT</pubDate>
<lastBuildDate>Sat, 13 Jan 2007 00:00:01 GMT</pubDate>
<docs>http://blogs.law.harvard.edu/tech/rss</docs>
<ttl>1440</ttl>
Here I’ve just added some additional information about my channel that will help news readers update it properly. Some confusion arises between the pubDate and the lastBuildDate. Many times these values are the same. Basically, the pubDate indicates when the newest content went live. The lastBuildDate indicates when the channel feed (rss page) was generated.
If I had a cron on my website that auto generated my RSS channel daily, it would update the lastBuildDate each time it ran. The pubDate would only be updated when it found new content. The lastBuildDate and pubDate should both be listed in GMT.
The ttl element tells news readers to only update my rss feed once a day. Since articles on Developer Shed are only released once a day, there’s no point checking any more than that.
Expanding your content listing
Now we’ll take a moment to list the additional sub-elements that relate to your channel items. The elements provide extra information specific to each piece of content offered.
|
Element |
Description |
|
author |
The email address of the content author. |
|
category |
Adds a category for your item. |
|
comments |
The URL of a page containing comments, such as blog or forum, relating to the item. |
|
enclosure |
Describes the media attached to an item. |
|
guid |
A unique string used to identify your item. |
|
pubDate |
The publication date of the item |
|
source |
The RSS channel that the item came from. |
Here I’ve added some additional elements to my channel item.
<item>
<title>A New Toolbar Can Boost Your Web Site Traffic Dramatically</title>
<description>Dev Articles - Embedded Tools - 1/10/07</description>
<link>http://www.devarticles.com/c/a/Embedded-Tools/A-New-Toolbar-Can-Boost-Your-Web-Site-Traffic-Dramatically</link>
<comments>http://www.devarticles.com/showblog/32759/A-New-Toolbar-Can-Boost-Your-Web-Site-Traffic-Dramatically</comments>
<guid>http://www.devarticles.com/c/a/Embedded-Tools/A-New-Toolbar-Can-Boost-Your-Web-Site-Traffic-Dramatically</guid>
<pubDate>Wed, 10 Jan 2007 00:13:01 GMT</pubDate>
</item>
I’ve used the comment sub-element to provide the URL for the article discussion blog. For the guid I just used the URL of the article since it’s always unique. Not setting item guids can prevent news readers from updating your listing properly. Making your feed available
Save your feed with either the rss or xml extension. The rss extension is used to indicate rss feeds, and the xml extension can be used since RSS 2.0 is xml based. Either one can be used interchangeably. If your site also contains older RSS feeds, I suggest using the rss extension to provide a sense of continuity.
Here’s my final RSS feed named feed.xml:
<?xml version="1.0" ?>
<rss version="2.0">
<channel>
<title>Popular Articles by Nilpo</title>
<description>Popular articles by Nilpo published by Developer Shed.</description>
<link>http://www.nilpo.com</link>
<language>en-us</language>
<copyright>Copyright © 2006,2007 Developer Shed, Inc.</copyright>
<managingEditor>contacteditor@developershed.com</managingEditor>
<pubDate>Sat, 13 Jan 2007 00:00:01 GMT</pubDate>
<lastBuildDate>Sat, 13 Jan 2007 00:00:01 GMT</pubDate>
<docs>http://blogs.law.harvard.edu/tech/rss</docs>
<ttl>1440</ttl>
<item>
<title>A New Toolbar Can Boost Your Web Site Traffic Dramatically</title>
<description>Dev Articles - Embedded Tools - 1/10/07</description>
<link>http://www.devarticles.com/c/a/Embedded-Tools/A-New-Toolbar-Can-Boost-Your-Web-Site-Traffic-Dramatically</link>
<comments>http://www.devarticles.com/showblog/32759/A-New-Toolbar-Can-Boost-Your-Web-Site-Traffic-Dramatically</comments>
<guid>http://www.devarticles.com/c/a/Embedded-Tools/A-New-Toolbar-Can-Boost-Your-Web-Site-Traffic-Dramatically</guid>
<pubDate>Wed, 10 Jan 2007 00:13:01 GMT</pubDate>
</item>
<item>
<title>SteelSound 3H Gaming Headset Review</title>
<description>Dev Hardware - Peripherals - 1/10/07</description>
<link>http://www.devhardware.com/c/a/Peripherals/SteelSound-3H-Gaming-Headset-Review</link>
<comments>http://www.devhardware.com/showblog/32760/SteelSound-3H-Gaming-Headset-Review</comments>
<guid>http://www.devhardware.com/c/a/Peripherals/SteelSound-3H-Gaming-Headset-Review</guid>
<pubDate>Wed, 10 Jan 2007 00:13:01 GMT</pubDate>
</item>
</channel>
</rss>
Any time that you need to use special characters in your channel elements, they should be html encoded. You’ll notice my use of the © html entity in my channel’s copyright element.
Once your have your RSS feed built, stop by feedvalidator.org to make sure that the syntax is valid. Once it is you can publish it to your website. Just provide a URL to the location of your rss or xml file for users to add to their news readers. You can also submit the URL to many listing services.
That’s all there is to it. You now have a live RSS feed. You can add additional items any time that new content becomes available on your site. Many CMS programs provide RSS creation for you. There are also a number of third party tools that can be used to generate the channel file for you.
