2.3 Structuring the Feed Itself

RSS feeds have their own internal structure. It is good to understand it now, because it allows you to see how your CMS can create an RSS feed in the most painless way. (Remember, if you don't have a CMS, you can still create RSS files with a simple text editor.)

At its most basic, a feed consists of a channel, with its own attributes, an image, and a number of items contained within the channel, each with their own individual attributes, like this:

  • Channel (title, description, URL, creation date, etc.)

  • Image

  • Item (title, description, URL, etc.)

  • Item (title, description, URL, etc.)

  • Item (title, description, URL, etc.)

At their heart, these items inside an RSS feed are simple links to other resources, with varying amounts of description associated with each item. There are subtleties to each RSS standard's version of what a "description" actually is and how much metadata can be given, and there are differing limits placed on which resources can be linked, but the basic aim is always the same.

For this reason, RSS feeds are always used with systems in which the content can be segmented into discrete sections or objects that can be linked.

News sites are good examples of this. News stories usually are broken into sections: headline, dateline, byline, body text, and so on, and some of these sections naturally map onto RSS fields. Weblogs are also good examples ? their content grows in easily discernable chunks, each usually with a definable link, title, description, and so on.

Therefore, when working to create RSS feeds it pays to think about how the different fields within your existing content can be reused. Indeed, with all markup languages converging on XML compliance, we foresee a CMS that holds stories in a database that can produce a heavily detailed master record, and then produces an RSS feed, XHTML documents for various devices, WML for mobile phones, and so on, all with appropriate levels of detail for their medium.

This technique also shows one reason behind the push from HTML to XHTML for web-page authoring. Separating the layout from the actual data allows for the data in the master record to be unencumbered with layout details; the data can then be transformed into different formats for different uses. This transformation works both ways, as we'll discuss in the next section.

This is not to say that RSS feeds can only be used to represent big lumps of structured information. Many people are now using RSS ? RSS 1.0, specifically ? as a conduit for many different types of object. Events, software patches, streaming audio information, television schedules, and address books can all be encoded as RSS. We'll discuss this in detail in Chapter 7.