It’s so simple to be happy, but so difficult to be simple.
—Gururaj Ananda Yogi
In this chapter we examine the RSS 0.91, 0.92, and 2.0 specifications in detail. We also show how to create your own feeds and use those created by others.
The version documented in this section is based on the Userland document of April 2000 (currently found at http://backend.userland.com/rss091). Its author, Dave Winer, did not invent any new practices with this specification, but he did codify RSS in a far more precise way than the Netscape original (at http://my.netscape. com/publish/formats/rss-spec-0.91.html), based on common practice at the time. Primarily, the new codification imposed limits on the number of characters allowed within each element.
The only major difference between the Userland spec and the original
Netscape write-up is that the Userland version lacks a document type
definition
(DTD) declaration. In fact,
Netscape RSS 0.91 is the only RSS
version with an official DTD, so most RSS parsers are used to dealing
without one. Including the declaration is therefore a matter of
personal preference (though it must be noted that useful character
entities such as ™
cannot be used
without it). Example 4-1 provides a DTD declaration
for those who wish to use one.
Example 4-1. The top of an RSS 0.91 document, with a DTD declaration
<?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">
The top level of an
RSS 0.91 document is the
<rss
version="0.91">
element. This is followed by a single channel
element. The channel
element contains the entire
feed contents and all associated metadata.
There are five required subelements of
channel
within RSS 0.91:
-
title
The name of the feed. In most cases, this is the same name as the associated web site. It can have a maximum of 100 characters.
-
link
A URL pointing to the associated web site. It can have a maximum of 500 characters.
-
description
Some words to describe your channel. This section cannot contain anything other than plain text (no HTML or other markup is allowed).
-
language
The code for the language in which the feed is written. A full list of these codes appears in Appendix A.
-
image
An element that contains subelements to describe the feed’s accompanying icon. It has three required and two optional subelements:
-
url
The URL of a GIF, JPG, or PNG image that corresponds to the feed. It can have a maximum of 500 characters, and it is required.
-
title
A description of the image, usually used within the ALT attribute of HTML’s
<img>
tag. It can have 100 characters, and it is required.-
link
The URL to which the image should be linked. This is usually the same as the
channel
-levellink
. It can have 500 characters, and it is required.-
width
andheight
The width and height of the icon, in pixels. The icons should be a maximum of 144 pixels wide by 400 pixels high. The emergent standard is 88 pixels wide by 31 pixels high. Both of these elements are optional.
-
There are ten optional
channel
subelements of RSS 0.91. Technically speaking, you can leave these
out altogether. However, you are encouraged to add them. Much of this
stuff is static — the content of the element never changes.
Placing it into your RSS template, or adding another line to a
script, is little work for the additional value of your
feed’s metadata. This is especially true for the
first three subelements listed here:
-
copyright
A copyright notice for the content in the feed. It can have a maximum of 10 characters.
-
managingEditor
The email address of the person to contact for editorial enquiries. It is suggested that this is in the format
name
@
example.com
(
FirstName LastName
)
. It can have a maximum of 100 characters.-
webMaster
The email address of the webmaster for this feed. It can have a maximum of 100 characters.
-
rating
The PICS rating for the feed. The maximum length is 500 characters. More information on PICS can be found at http://www.w3.org/PICS/.
-
pubDate
The publication date of the content within the feed. For example, a daily morning newspaper publishes at a certain time early every morning. Technically, any information in the feed should not be displayed until after the publication date. Few RSS readers take any notice of this element in this way. Nevertheless, it should be in the format outlined in RFC 822. This element is also demonstrated in Example 3-2.
-
lastBuildDate
The date and time, RFC 822-style, that the feed last changed.
-
docs
A URL that points to an explanation of the standard, for future reference. This should point to either http://backend.userland.com/rss091 or http://my.netscape.com/publish/formats/rss-spec-0.91.html.
-
skipDays
andskipHours
A set of elements that can control when a feed user reads the feed.
skipDays
can contain up to sevenday
subelements: Monday, Tuesday, Wednesday, Thursday, Friday, Saturday, or Sunday.skipHours
contains up to 24hour
subelements, the numbers 1-24, representing the time in Greenwich Mean Time (GMT). The client should not retrieve the feed during any day or hour listed within these two elements. For example usage, see Example 3-2.-
textInput
An element that gives RSS feeds the ability to display a small text box and Submit button and associate them with a CGI application. Many RSS parsers support this feature, and many sites use it to offer archive searching or email newsletter sign-ups, for example.
textInput
has four required subelements:-
title
The label for the Submit button. It can have a maximum of 100 characters.
-
description
Text to explain what the
textInput
actually does. It can have a maximum of 500 characters.-
name
The name of the text object that is passed to the CGI script. It can have a maximum of 20 characters.
-
link
The URL of the CGI script. It can have a maximum of 500 characters.
-
RSS 0.91 can take up to 15
item
elements. The item
element
is at the heart of RSS, containing the primary content of the feed.
Technically, item
elements are optional, but a
syndication feed with no item
s is just a glorified
link. Not having any item
s does not mean the feed
is invalid; it just means that the feed may be extremely boring.
item
takes two mandatory subelements and one
optional subelement:
The link
and url
elements can begin with only
http://
or ftp://
. Note that
https://
, file
:,
mailto
:, news
:, and
javascript
: are not permitted.
Also not permitted inside any element within RSS 0.91 is any form of HTML. Even entity-encoded HTML is forbidden.
Example 4-2 shows the complete Userland RSS 0.91 specification in action.
Example 4-2. The complete Userland RSS 0.91 specification in action
<?xml version="1.0" encoding="ISO-8859-1" ?> <rss version="0.91"> <channel> <title>RSS0.91 Example</title> <link>http://www.oreilly.com/example/index.html</link> <description>This is an example RSS0.91 feed</description> <language>en-gb</language> <copyright>Copyright 2002, Oreilly and Associates.</copyright> <managingEditor>editor@oreilly.com</managingEditor> <webMaster>webmaster@oreilly.com</webMaster> <rating> <!-- See the text --> </rating> <pubDate>03 Apr 02 1500 GMT</pubDate> <lastBuildDate>03 Apr 02 1500 GMT</lastBuildDate> <docs>http://backend.userland.com/rss091</docs> <skipDays> <day>Monday</day> </skipDays> <skipHours> <hour>20</hour> </skipHours> <image> <title>RSS0.91 Example</title> <url>http://www.oreilly.com/example/images/logo.gif</url> <link>http://www.oreilly.com/example/index.html</link> <width>88</width> <height>31</height> <description>The World's Leading Technical Publisher</description> </image> <textInput> <title>Search</title> <description>Search the Archives</description> <name>query</name> <link>http://www.oreilly.com/example/search.cgi</link> </textInput> <item> <title>The First Item</title> <link>http://www.oreilly.com/example/001.html</link> <description>This is the first item.</description> </item> <item> <title>The Second Item</title> <link>http://www.oreilly.com/example/002.html</link> <description>This is the second item.</description> </item> <item> <title>The Third Item</title> <link>http://www.oreilly.com/example/003.html</link> <description>This is the third item.</description> </item> </channel> </rss>
Get Content Syndication with RSS now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.