Create an RSS 2.0 document from a template.
RSS 2.0 is an update of RSS 0.91, and so does not follow the RDF approach taken by RSS 1.0. After RSS 0.91 and RSS 1.0, it is the third most popular RSS format. You can find the spec for RSS 2.0 at http://blogs.law.harvard.edu/tech/rss. It is similar to RSS 0.91, but offers some clarifications and additional elements.
The following, news.xml , is a minimal example of RSS 2.0:
<rss version="2.0"> <channel> <title>Wy'east Communications</title> <link>http://www.wyeast.net</link> <description> Wy'east Communications is an XML consultancy.</description> <item> <title>Legend of Wy'east</title> <link>http://www.wyeast.net/wyeast.html</link> <description>The Native American story behind the name Wy'east.</description> </item> </channel> </rss>
Like RSS 0.91, RSS 2.0 doesn’t declare a namespace
for its own elements. Also like 0.91, rss
is the
document element. It must have a version
attribute
with a value of 2.0
.
The channel
element is required, as are its
children title
, link
, and
description
. The language
element is required as a child of channel
by 0.91,
but under 2.0 it is optional. The image
element is
also required by 0.91; it’s optional under 2.0.
Table 6-2 compares the required and optional
elements of channel
in 2.0 and 0.91. The purpose
of each is briefly described.
Table 6-2. Child elements of channel in RSS 2.0 and RSS 0.91
Element |
Purpose |
RSS 2.0 |
RSS 0.91 |
---|---|---|---|
|
Title of channel |
Required |
Required |
|
Link to channel |
Required |
Required |
|
Description of channel |
Required |
Required |
|
Language code for channel |
Optional |
Required |
|
Image that represents the channel (required children
|
Optional |
Required |
|
Copyright notice for the channel |
Optional |
Optional |
|
Email address of managing editor |
Optional |
Optional |
|
Email address of webmaster |
Optional |
Optional |
|
Publication date of channel in RFC 822 format,
|
Optional |
Optional |
|
Last time channel content changed in RFC 822 format, |
Optional |
Optional |
|
Platform for Internet Content Selection (PICS) rating (http://www.w3.org/PICS/) |
Optional |
Optional |
|
Documentation for the RSS format used by channel |
Optional |
Optional |
|
A text input box for the channel, such as a search box (required
children include |
Optional |
Optional |
|
Days to skip reading channel |
Optional |
Optional |
|
Hours to skip reading channel |
Optional |
Optional |
|
One or more channel categories |
Optional |
N/A |
|
Name of generator program |
Optional |
N/A |
|
Specifies a protocol for publishing and subscribing to feeds |
Optional |
N/A |
|
Optional |
N/A |
Under the item
element in RSS 2.0, a
description
element can contain entity-encoded
HTML. In other words, it can hold an article or story in itself,
written in HTML (with &
for
&
and <
for
<
). Table 6-3 compares the
0.91 and 2.0 children of
item
.
Table 6-3. Child elements of item in RSS 2.0 and RSS 0.91
Element |
Purpose |
RSS 2.0 |
RSS 0.91 |
---|---|---|---|
|
Title of item |
Optional /Required |
Required |
|
Link to item |
Optional /Required |
Required |
|
Description of item |
Optional /Required |
Optional |
|
Email address of author of item |
Optional |
N/A |
|
One or more item categories (optional attribute
|
Optional |
N/A |
|
URL for comment page for item |
Optional |
N/A |
|
Describes an object attached to |
Optional |
N/A |
|
Globally unique identifier |
Optional |
N/A |
|
Publication date in RFC 822 format |
Optional |
N/A |
|
RSS channel the item came from (required attribute
|
Optional |
N/A |
An item
element may represent a story such as an
article from a newspaper or a magazine. In such a case, the
item
’s
description
child should contain a synopsis of the
story, with a URI in the link
element pointing to
the full story. On the other hand, an item
may
also contain a complete story. In this case, the
description
child of item
will
contain the text of the whole story (which may be entity-encoded
HTML), so the link
and title
children of item
don’t have to be
included. Though all elements of item
are optional
in 2.0, at least one title
or
description
must be present.
RSS 2.0 restricts the first non-whitespace characters in the content
of link
and url
elements. This
content must begin with a URI scheme registered at IANA (http://www.iana.org/assignments/uri-schemes),
such as ftp://
, http://
,
https://
, mailto
:, or
news://
. RSS 0.91 allows only
http://
and ftp://
.
3.149.214.32