Here's an adapted version of Wired News' 0.91 RSS feed, including just the most basic of RSS elements, and links to two stories:
<?xml version="1.0" ?>
<!DOCTYPE rss PUBLIC "-//Netscape Communications//DTD RSS 0.91//EN"
"http://my.netscape.com/publish/formats/rss-0.91.dtd">
<rss version="0.91">
<channel>
<title>Wired News
</title>
<link>http://www.wired.com/
</link>
<description>
Technology, and the way we do business, is changing the world we know....
</description>
<language>en-us
</language>
<item>
<title>
Techs Tangle With Privacy Regs
</title>
<link>
http://www.wired.com/news/medtech/0,1286,58468,00.html
</link>
<description>
The deadline has past for complying with the 1996 Health Insurance
Portablility and Accountability Act, a sweeping law designed to protect
the privacy of people's medical records. </description>
</item>
<item>
<title>
SARS Gene Sequence Unveiled
</title>
<link>
http://www.wired.com/news/medtech/0,1286,58481,00.html
</link>
<description>
Scientists have uncovered the genome sequence for severe acute
respiratory syndrome, which may help develop better diagnostics.
</description>
</item>
</channel>
</rss>
What do you see? Some funny-looking tags, perhaps, but it's a lot like HTML and XML, isn't it? Since RSS is an application of XML, RSS feeds must be built as well-formed XML so when you open a tag, remember to close and nest it properly. Sloppy code won’t work here.
The XML rigmarole likewise requires the first two lines, first defining the XML version and then setting a Document Type Definition. If you don't know what that means, no worries. Just cut and paste those opening lines, they're the same for every 0.91 feed.
Next in line is general information about your site, or metadata. Roughly akin to the <head> of an HTML file, this portion of the feed stays the same as updates are added. Here's where you can start replacing tidbits to tailor it to your site.
Here’s tag-by-tag commentary:
<RSS>: This opening tag includes a mandatory version attribute. Note that the </rss> tag also concludes our feed.
<channel>: The channel is the fundamental container for all RSS data there's only one channel in a feed. Note that the channel tag gets closed near the very end of the feed, too.
<link>: The URL for the webpage that corresponds to the RSS feed. (Most likely, this is your homepage's URL.)
<title>: Hey, the title! This is most likely going to be the same title as your homepage.
<description>: A brief description of what's in this feed, or the purpose of your site.
<language>: This states what language your feed is in. "en-us" is American English, but as the complete list of allowable <language> values shows, there are several English variants along with a myriad of other languages.
Now, onto the <item>s the dynamic headlines, links, and content you'll be syndicating. When you update your site and add new stories, new items are added to the RSS feed. Each <item> represents a separate story or content update. Up to 15 items can be included in RSS 0.91.
<item>: This wrapper tag is required around every item
<link>: The URL of an item.
<description>: A synopsis or excerpt of the item, although you're free to publish the entirety of the item here, as is many peoples' practice.
Two pieces of advice to heed while creating your <description>: Firstly, put in the extra effort to create a well-written, easy-to-read description. In the text-centric world of RSS, you can't expect an audience to click through to your site if your "teaser" excerpt has little appeal or sense to it. Secondly, if there is HTML code in your description, XML parsers throw a fit unless certain HTML symbols (like the ampersand) are escaped out. Either keep HTML out of your description altogether, or encode it via CDATA, like so:
I would <![CDATA[<b>really</b>]]> rather have just dropped the bold tag.
And that's it. Done!
Next, let's validate and automate.
next page»