XML Tutorials
  Home arrow XML Tutorials arrow Page 3 - RSS 2.0
Codewalker Forums 
  Tutorials  
Database Articles  
Miscellaneous  
Navigation Usability  
PEAR Articles  
Programming Basics  
Server Administration  
XML Tutorials  
  Reviews  
Database Book Reviews  
Linux Book Reviews  
Miscellaneous Reviews  
PHP Book Reviews  
PHP Software Reviews  
Server Admin Reviews  
SQL Tool Reviews  
  Code Gallery  
Content Management Code  
Contest Code  
Counters Code  
Database Code  
Date Time Code  
Discussion Board Code  
Email Code  
File Manipulation Code  
GUI Code  
Link Farm Code  
Miscellaneous Code  
Search Code  
Site Navigation Code  
User Management Code  
Forums Sitemap 
Dedicated Servers  
Download TestComplete 
JMSL Numerical Library 
IBM® developerWorks
Weekly Newsletter 
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
XML TUTORIALS

RSS 2.0
By: O'Reilly Media
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 1
    2008-04-03

    Table of Contents:
  • RSS 2.0
  • The Basic Structure
  • item Elements
  • The Simplest Possible RSS 2.0 Feed

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    RSS 2.0 - item Elements


    (Page 3 of 4 )

    RSS 2.0 can have any number of item elements. The item element is at the heart of RSS; it contains the primary content of the feed. Technically, item elements are optional, but a syndication feed with no items is just a glorified link. Not having any items doesn't mean the feed is invalid, just extremely boring.

    All item subelements are optional, with the proviso that at least one of item/title or item/description is present. You can use this feature to build lists (more on that later).

    With item, there are the 10 standard item subelements available:

    title

    Usually, this is the title of the story linked to by the item, but it can also be seen as a one-line list item. There is controversy over whether HTML is allowed within this element; for more information, see the sidebar "Including HTML Within title or description."

    link

    The URL of the story the item is describing.

    description

    A synopsis of the story. The description can contain entity-encoded HTML. Again, as with item/title, see the pertinent sidebar "Including HTML Within title or description."

    author

    This should contain the email address of the resource's author referred to within the item. The specification's example is in the format user@example.com
    (firstname lastname) but isn't explained further:

      <author>ben@benhammersley.com (Ben Hammersley)</author>

    category

    Exactly the same as channel/category, but it pertains to the individual item only:

      <category domain="the twisted passages of my mind">up/to_the_left/there</category>

    comments

    This should contain the URL of any comments page for the item; it's primarily used with weblogs:

      http://www.example.com/comments.cgi?post=12345

    enclosure

    This describes a file associated with an item. It has no content, but it takes three attributes: url is the URL of the enclosure, length is its size in bytes, and type is the standard MIME type for the enclosure. Some feed applications can download these files automatically. The original idea was for configuring a feed aggregator to automatically download large media files overnight, thereby deferring the extra bandwidth required. This is an underused feature of RSS 2.0 because most aggregators don't support it, but in 2004, it became the focus of a lot of development around the idea of podcasting. See the sidebar "Including HTML Within title or description" for details.

      <enclosure url="http://www.example.com/hotxxxpron.mpg" length= "34657834"
      type="video/mpeg"/>

    guid

    Standing for Globally Unique Identifier, this element should contain a string that uniquely identifies the item. It must never change, and it must be unique to the object it is describing. If that content changes in any way, it must gain a new guid. This element also has the optional attribute isPermalink, which, if true, denotes that the value of the element can be taken as a URL to the object referred to by the item. Therefore, if no item/link element is present, but the isPermalink attribute is set to true, the application can take the value of guid in its place. The specification doesn't say what to do if both are present and aren't the same, but it seems sensible to give preference within any application to the item/link element.

      <guid isPermalink="true">http://www.example.com/ example.html</guid>

    pubDate

    The publication date of the item. Again, as with channel/pubDate, any information in the item shouldn't be displayed until after the publication date, but few existing RSS readers take any notice of this element in this way. The date is in RFC 822 format.

      <pubDate>Mon, 13 Sep 2004 00:23:05 GMT</pubDate>

    source

    This should contain the name of the feed of the site from which the item was derived, and the attribute url should be the URL of that other site's feed:

      <source url="http://www.metafilter.com/rss.xml"> Metafilter</source>

    Example 4-1 shows these parts assembled into an RSS 2.0 XML document.

    Example 4-1. An example RSS 2.0 feed

    <?xml version="1.0"?>
    <rss version="2.0">
    <channel>
     
    <title>RSS2.0Example</title> 
      <link>http://www.exampleurl.com/example/ index.html</link>
      <description>This is an example RSS 2.0 feed</description>
      <language>en-gb</language>
      <copyright>Copyright 2002, Oreilly and Associates.</copyright> 
      <managingEditor>example@exampleurl.com </managingEditor> 
      <webMaster>webmaster@exampleurl.com </webMaster>
      <rating> </rating>
      <pubDate>03 Apr 02 1500 GMT</pubDate>
      <lastBuildDate>03 Apr 02 1500 GMT</lastBuildDate> 
      <docs>http://blogs.law.harvard.edu/tech/ rss</docs>
      <skipDays><day>Monday</day></skipDays>
      <skipHours><hour>20</hour></skipHours>
      <category domain="http://www.dmoz.org">Business/ Industries/Publishing/Publishers/

    Nonfiction/Business/O'Reilly_and_Associates/ </category> 
      <generator>NewsAggregator'o'Matic </generator>
      <ttl>30<ttl>
      <cloud domain="http://www.exampleurl.com" port="80" path="/RPC2"
    registerProcedure="pleaseNotify" protocol="XML-RPC" />

      <image>
        <title>RSS2.0 Example</title> 
        <url>http://www.exampleurl.com/example/ images/logo.gif</url> 
        <link>http://www.exampleurl.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.exampleurl.com/example/ search.cgi</link>
     
    </textInput>

      <item>
        <title>The First Item</title> 
        <link>http://www.exampleurl.com/example/ 001.html</link>
        <description>This is the first item.</description>
        <source url="http://www.anothersite.com/ index.xml">Another Site</source>
        <enclosure url="http://www.exampleurl.com/example/001.mp3" length="543210" 
                           type"audio/mpeg"/>
        <category domain="http://www.dmoz.org">Business/ Industries/Publishing/Publishers/

    Nonfiction/Business/O'Reilly_and_Associates/ </category> 
        <comments>http://www.exampleurl.com/ comments/001.html</comments>
        <author>Ben Hammersley</author>
        <pubDate>Sat, 01 Jan 2002 0:00:01 GMT</pubDate>
        <guid isPermaLink="true">http://www.exampleurl.com/ example/001.html</guid>
     
    </item>

      <item>
        <title>The Second Item</title>
        <link>http://www.exampleurl.com/example/ 002.html</link>
        <description>This is the second item.</description>
        <source url="http://www.anothersite.com/index.xml"> Another Site</source>
        <enclosure url="http://www.exampleurl.com/example/ 002.mp3" length="543210"
                           type"audio/mpeg"/>
        <category domain="http://www.dmoz.org">Business/ Industries/Publishing/Publishers/
    Nonfiction/Business/O'Reilly_and_Associates/ </category>
        <comments>http://www.exampleurl.com/ comments/002.html</comments>
        <author>Ben Hammersley</author>
        <pubDate>Sun, 02 Jan 2002 0:00:01 GMT</pubDate>
        <guid isPermaLink="true">http://www.exampleurl.com/ example/002.html</guid>
     
    </item>

      <item>
        <title>The Third Item</title>
        <link>http://www.exampleurl.com/example/ 003.html</link>
        <description>This is the third item.</description>
        <source url="http://www.anothersite.com/ index.xml">Another Site</source>
        <enclosure url="http://www.exampleurl.com/example/ 003.mp3" length="543210"
                           type"audio/mpeg"/>
        <category domain="http://www.dmoz.org">Business/ Industries/Publishing/Publishers/
    Nonfiction/Business/O'Reilly_and_Associates/ </category> 
        <comments>http://www.exampleurl.com
    /comments/003.html</comments>
        <author>Ben Hammersley</author>
        <pubDate>Mon, 03 Jan 2002 0:00:01 GMT</pubDate>
        <guid isPermaLink="true">http://www.exampleurl.com
    /example/003.html</guid>
      </item>
    </channel>
    </rss>

    More XML Tutorials Articles
    More By O'Reilly Media


       · This article is an excerpt from the book "Developing Feeds with RSS and Atom,"...
     

    Buy this book now. This article is excerpted from chapter four of the book Developing Feeds with RSS and Atom, written by Ben Hammersley (O'Reilly; ISBN: 0596008813). Check it out today at your favorite bookstore. Buy this book now.

    XML TUTORIALS ARTICLES

    - Creating RSS 2.0 Feeds
    - Using Modules in Your RSS Feed
    - RSS 2.0
    - Querying XML: Use Cases
    - Joins and Query Use with XML
    - Solving Problems by Querying XML
    - Performing Set Operations When Querying XML
    - Querying XML
    - Handling Data for Ajax with JSON
    - Handling XML Data for Ajax
    - XML and JSON for Ajax






    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway