What Is RSS?


When you discuss RSS, you have to specify which format of RSS you mean. RSS has gone through a number of iterations since it was first published as RSS 0.90 by Netscape back in 1999. The following table discusses the versions of RSS you are likely to encounter.

Open table as spreadsheet

Version (Year)

Comments

0.90 (1999)

RDF Site Summary was the initial public version of RSS and was intended as a syndication format for their portal (http://www.my.netscape.com). As the title indicates, it was based on the Resource Description Framework (RDF). More information on this version is available from the specification page listed in the resource section at the end of this chapter.

0.91 (1999 and 2000)

Netscape's version was a simplification of the 0.90 version. It removed the need for the document to be RDF compatible. A DTD was available for validation as part of the specification.

 

Dave Winer's version was (in his own words) a cleanup of Netscape's 0.91. In addition, it was an attempt to maintain forward momentum of RSS. The specification is similar to Netscape's RSS 0.91 with the removal of the DTD requirement. This was the most available version of RSS for a while, although I think it is now surpassed by RSS 2.0.

0.92 (2000)

An updated version of Userland's 0.91 specification. This version was fairly broadly available, and a number of feeds in this format are still available today. The most important additions to 0.91 were the enclosure and category elements of item.

1.0 (2000)

A new version initially created to be less ambiguous than previous versions. RSS 1.0 has no relation to the previous versions and was based on RDF. This version is described in this specification.

2.0 (2002)

Also known as version 0.94. This is an updated version of 0.92 that includes optional elements. There is no relationship between version 1.0 and 2.0. This is the first version in the 0.9x/2.0 family that included support for extending RSS via namespaces directly in the specification.

With all these versions "in the wild," you may be confused about how to write code to process RSS. However, these versions really fit into two main families: the RSS 0.9 x/2.0 family and the RSS 1.0 family. As each new version of the 2.0 family was designed, developers maintained backward compatibility as much as possible. Therefore, a parser written to work with version 2.0 should work with versions 0.91 and 0.92 as well. Listing 18-1 shows a sample RSS 2.0 document, and Listing 18-2 shows an RSS 1.0 document.

Listing 18-1: A sample RSS 2.0 feed

image from book
      <?xml version="1.0" encoding="utf-8"?>      <ddd><rss xmlns:dc="http://purl.org/dc/elements/1.1/" version="2.0"></ddd>        <channel>          <title>MSDN: Microsoft XML Developer Center</title>          <link>http://msdn.microsoft.com/xml/</link>          <description>The latest information from the Microsoft XML Developer      Center.</description>          <language>en-us</language>          <pubDate>Sat, 22 Oct 2005 13:01:25 GMT</pubDate>          <lastBuildDate>Sat, 22 Oct 2005 13:01:25 GMT</lastBuildDate>          <generator>MSDN RSS Service 1.1.0.0</generator>          <ttl>1440</ttl>          <item>            <title>XML for Fun: Displaying Your iTunes Library</title>            <description>In this week's article show you how to extract your song      library as XML from iTunes so that you can use the data from within other      applications as well.</description>      <link>http://msdn.microsoft.com/coding4fun/xmlforfun/ITunesLib/default.aspx</link>            <dc:creator>Peter Bernhardt</dc:creator>            <guid isPermaLink="false">Titan_1166</guid>            <pubDate>Fri, 24 Jun 2005 17:13:48 GMT</pubDate>          </item>          <item>            <title>Introduction to XQuery in SQL Server 2005</title>            <description>Discover how XQuery works in SQL Server 2005: the FLWOR      statement, operators in XQuery, the if-then-else construct, XML constructors,      built-in XQuery functions, type casting operators, and more.</description>            <link>http://msdn.microsoft.com/sql/default.aspx?pull=/library/en-      us/dnsql90/html/sql2k5_xqueryintro.asp</link>            <dc:creator>Prasadarao K. Vithanala</dc:creator>            <guid isPermaLink="false">Titan_851</guid>            <pubDate>Wed, 15 Jun 2005 18:42:31 GMT</pubDate>          </item>        </channel>      </rss> 
image from book

Important points to note in this feed are:

  • q The root element is rss.

  • q There is no defined schema for this feed type, nor is there a default namespace.

  • q It uses namespaces to provide extensions.

Listing 18-2 shows a sample RSS 1.0 feed.

Listing 18-2: A sample RSS 1.0 feed

image from book
      <?xml version='1.0' encoding='utf-8'?>      <ddd><rdf:RDF      xmlns:rdf='http://www.w3.org/1999/02/22-rdf-syntax-ns#'      xmlns:dc='http://purl.org/dc/elements/1.1/'      xmlns='http://purl.org/rss/1.0/'></ddd>      <channel rdf:about='http://www.xml.com/'>      <title>XML.com</title>      <link>http://www.xml.com/</link>      <description>XML.com Articles and Weblogs</description>      <dc:rights>Copyright 2005, O'Reilly Media, Inc.</dc:rights>      <dc:language>en-us</dc:language>      <items>      <rdf:Seq>      <rdf:li rdf:resource='http://www.xml.com/pub/a/2005/11/09/fixing-ajax      xmlhttprequest-considered-harmful.html' />      <rdf:li rdf:resource='http://www.xml.com/pub/a/2005/11/09/rexml-processing-xml-in-      ruby.html' />      </rdf:Seq>      </items>      </channel>      <item rdf:about='http://www.xml.com/pub/a/2005/11/09/fixing-ajax-xmlhttprequest-      considered-harmful.html?CMP=OTC-TY3388567169'>       <title>Fixing AJAX: XmlHttpRequest Considered Harmful</title>       <link>http://www.xml.com/pub/a/2005/11/09/fixing-ajax-xmlhttprequest-considered-      harmful.html?CMP=OTC-TY3388567169</link>       <description><![CDATA[<img src='/books/2/381/1/html/2/http://www.xml.com/2005/11/09/graphics/111-      bad_httpreq.gif' width='111px' height='91px' alt='tile image' align='left' />Jason      Levitt shows us how to work around XmlHttpRequest restrictions in order to get more      joy from third-party web services.]]></description>       <dc:creator>Jason Levitt</dc:creator>       <dc:date>2005-11-09T15:20:36-08:00</dc:date>      </item>      <item rdf:about='http://www.xml.com/pub/a/2005/11/09/rexml-processing-xml-in-      ruby.html?CMP=OTC-TY3388567169'>       <title>REXML: Processing XML in Ruby</title>       <link>http://www.xml.com/pub/a/2005/11/09/rexml-processing-xml-in-      ruby.html?CMP=OTC-TY3388567169</link>       <description><![CDATA[<img src='/books/2/381/1/html/2/http://www.xml.com/2005/11/09/graphics/111-      ruby.gif' width='111px' height='91px' alt='tile image' align='left' />Ruby web      apps, including those built with Rails, don't always use XML to represent data. But      sometimes you just don't have a choice. Koen Vervloesem shows us how to process XML      in Ruby using Ruby Electric XML (REXML).]]></description>       <dc:creator>Koen Vervloesem</dc:creator>       <dc:date>2005-11-09T15:16:47-08:00</dc:date>      </item>      </rdf:RDF> 
image from book

Major points to note in this example are:

  • q The root element is rdf:RDF. RSS 1.0 depends heavily on the Resource Description Framework (RDF) specification.

  • q The use of namespaces to provide extension support.

  • q Heavy reliance on Dublin Core to provide metadata, such as post date/time, creator, and language.

  • q The use of rdf:about to provide an URI for each major element (channel, item).

  • q The use of the rdf:Seq block to identify the order of the items in the feed.

  • q The use of CDATA blocks to encode HTML content in the description (this is actually common in RSS 2.0 feeds as well).




Professional XML
Professional XML (Programmer to Programmer)
ISBN: 0471777773
EAN: 2147483647
Year: 2004
Pages: 215

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net