In the previous article we discussed how to read an RSS file with PHP. In this article we will focus on the theoretical aspects of how to build an RSS file.
RSS is an acronym for Really Simple Syndication. It is used to provide information about your website to the world. There is not really any difference between an XML document and an RSS document; in fact most people would agree that RSS is an XML dialect. All RSS documents must conform to the XML specification, which is published on the W3C website. We have several different versions of RSS formats. Let me explain why.
RSS was first invented by Netscape. They wanted to use an XML format to distribute news, stories and information for their My Netscape Portal back in the mid 1990s. For some reason Netscape lost interest in RSS and abandoned it just as it was becoming popular, and a company called Userland started to develop it for use in its products. As the format became more popular, the question of ownership of the RSS format became a problem when both Netscape and Userland claimed it as their own. To cut a long story short, we now have several versions of the RSS format, developed by various companies and individuals.
There are many RSS variations available today, and most RSS readers can still read the earliest, version 0.91. The latest version is 2.0, and can also be read by most RSS readers. There are two kinds of RSS documents. There's what I call the simple kind and the enhanced kind. The enhanced version of an RSS document includes, in addition to the required elements, the following optional elements:
Table 1.
Element
Description
Example
Managing Editor
Email address for person responsible for editorial content.
jd@mysite.com (John Doe)
WebMaster
Email address for person responsible for technical issues relating to the channel.
jd@mysite.com (John Doe)
Copyright
Copyright notice of the content in the channel.
Copyright 2006, JD Site
Language
Language used in the channel. Allows aggregators to group articles by language.
En-us
pubdate
Publication date of the content in the channel.
Fri, 05 Sep 2005 00:00:001 GMT
LastBuildDate
The date of the last time the content changed.
Fri, 05 Sep 2005 00:00:001 GMT
Generator
The name of program that generated the document.
JD RSS Content Builder
docs
A URL that points to a site that would give information about the format used to create this RSS document.
www.wc3.com
image
Specifies an image that can be displayed with the channel.
Myimage.gif
clouds
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 stands for time to live. It's a number of minutes that indicates how long a channel can be cached before refreshing from the source.
<ttl>40</ttl>
rating
The PIC rating for the channel.
textinput
Specifies a text input box that can be displayed with the channel. Further details:
A channel may optionally contain a <textInput> sub-element, which contains four required sub-elements:
<title> -- The label of the Submit button in the text input area.
<description> -- Explains the text input area.
<name> -- The name of the text object in the text input area.
<link> -- The URL of the CGI script that processes text input requests.
skipHours
A hint for aggregators telling them which hours they can skip. Further details:
An XML element that contains up to 24 <hour> sub-elements whose value is a number between 0 and 23, representing a time in GMT, when aggregators, if they support the feature, may not read the channel on hours listed in the skipHours element.
Let me say a few words about the above optional elements. First of all, these are not all the optional elements that are available; I've just picked the ones I thought were most relevant to my article. If you want a list of all of them you should visit one of the many websites devoted to RSS document creation.
Secondly, ALL dates must conform to the RFC 822 specification as in the examples in Table 1.
All these specifications and rules were created because in the past, developers of RSS readers found that their readers could not read all RSS documents, because everybody created RSS documents as they wished. So a common approach to RSS document formatting was agreed upon, with a minimum standard to enable any RSS reader to read any RSS document.