XML technologies / RSS & Atom / RSS 2.0 / The RSS 2.0 vocabulary / Basic structure of an RSS 2.0 document

(Excerpt from "Newsfeeds with RSS and Atom" by Heinz Wittenbrink, published by Galileo Press, 2005)

The following sample contains only the RSS 2.0 elements required by every feed in this format.

<?xml version="1.0"?>
<rss version="2.0">
   <channel>
      <title>Webtrends</title>
      <link>http://www.celawi.eu/webtrends.html</link>
      <description>Nachrichten über kommerzielle Websites und Online-Werbung</description>
      <item>
         <title>Ask Jeeves jetzt auch in Spanien</title>
         <link>http://www.celawi.eu/webtrends/20040415_01.html</link>
         <description>Ask Jeeves startete am 5. April mit der Betaversion eines neuen Such-Service für Spanien. Es ist der erste von mehreren geplanten Starts in Europa dieses Jahr. Momentan ist noch keine Werbung auf den Ergebnisseiten von Ask Jeeves España geschaltet.</description>
      </item>
      <item>
         <title>Bitkom-Studie: Paid Content in Deutschland erfolgreich</title>
         <link>http://www.celawi.eu/webtrends/20040415_02.html</link>
         <description>Kostenpflichtige Online-Inhalte werden immer besser angenommen: "Die Zeit der Kostenlos-Kultur geht zu Ende, gleichzeitig steigt die Qualität der Angebote", sagt Bernhard Rohleder, Hauptgeschäftsführer von Bitkom.</description>
      </item>
   </channel>
</rss> 

Code example: simple RSS document

Illustrations of this document in offline and online newsreaders are available under Minimum information.

The document has a simple, clear structure, with tag names often explaining their meaning. The following illustration shows its tree structure.

Six elements form the RSS 2.0 core: rss, channel, item, link, title and description. Three provide structure; the others provide content.

The elements channel, item, link, title and description were introduced under "Minimum information". They perform tasks fundamental to syndication, allowing a newsfeed to act as a snapshot of a Web resource’s current state. They also allow feeds to be combined or "aggregated". Other formats have semantically equivalent constructs. In RSS 1.0 the names match RSS 2.0; Atom replaces channel and item with the element types feed and entry.

Tree diagram of a simple RSS document

Figure: tree diagram of a simple RSS document

XML declaration and RSS version: defining the language

The document starts with an XML declaration (XML declaration). It is recommended, not required. As in almost all existing XML documents, version 1.0 is used. XML 1.1 has since been adopted with only minor differences. RSS 2.0 requires conformance to XML 1.0.

The rss element (document element)

Like any XML document, RSS has exactly one root or document element, named rss. The root merely tells processing software that it contains RSS information. The value of its attribute version specifies the RSS version, telling the processor that the content follows RSS 2.0’s rules.

For its own elements, RSS 2.0 ignores a major XML specification, XML Namespaces. Like earlier versions, RSS 2.0 declares no namespace. Namespaces may nevertheless be used for extensions. For rss see also the page The rss element in the RSS 2.0 reference.

Organizing an RSS 2.0 document with channel and item

The elements channel and item have three functions:

  1. They structure an RSS document.

  2. They represent a whole Web resource (channel) or its parts (item).

  3. They contain descriptions of the properties of the resource and its parts.

Every RSS document describes one channel that may contain any number of item elements.

channel contains the elements describing the resource as a whole. How many item elements descend from channel is up to the document’s author. Documents with no element of type item are also possible.

As the code example showed, the element channel is always nested in an element named rss. The element channel essentially contains no information beyond the element rss. Other formats avoid separate elements for the language type and whole feed, identifying their vocabulary through a namespace attribute on the root. Atom’s root, for example, is feed.

No further structural levels are needed or possible. The order of elements inside channel or item is not prescribed.

All descendants of channel except item describe feed properties; all children of item describe individual entry properties. The English element name almost always explains the information.

RSS 2.0 permits a channel to have far more child elements than an item. The elements channel and item share, beyond the required children of channel ( title, link and description ), also the elements category and pubDate. Only an item is described by the elements author, comments, enclosure, guid and source. Only as descendants of the element channel occur the elements language, copyright, managingEditor, webMaster, lastBuildDate, generator, docs, cloud, ttl, image, rating, textInput, skipHours and skipDays. For channel see also the page The channel element in the RSS 2.0 reference.

The item element

When explaining the function of the element item the RSS specification is vague. An individual item may reference an existing information object or publish a new one that exists nowhere else. The specification says an item may describe a "story" or be self-contained. Dave Winer calls the first case a story like one in a newspaper or magazine. The description is then an abstract and link points to the full version. Otherwise, the description contains the full text and link and title may be omitted. RSS 2.0 therefore has only optional descendants of item; every such element must nevertheless have a child named title or one named description. For item see also the page The item element in the RSS 2.0 reference.

   

 

 

 

Creative Commons license
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.

back to top