SunQuest
 
       XML Tutorials
  Home arrow XML Tutorials arrow Page 4 - Creating RSS 2.0 Feeds
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 
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

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

    Table of Contents:
  • Creating RSS 2.0 Feeds
  • guid, Permalink or not
  • Creating RSS 2.0 with PHP
  • Caching and saving

  • 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

    Stay one step ahead of the competition. Evaluate and give feedback on some of the hottest web development tools on the market today. Make your opinion heard! Click Here

    Creating RSS 2.0 Feeds - Caching and saving


    (Page 4 of 4 )

    One advantage that the FeedCreator class has over Perl's XML::RSS is the built-in caching mechanism. PHP is mostly used, in this case, as a way of dynamically building a feed upon request, perhaps from a database. However, when a feed gets too popular, that might cause too much of a server load. You can have your script store a cache file and serve that instead of running itself by adding this line:

      $rss->useCached();

    This saves the dynamically created feed to a cache, serving that instead if it is less than one hour old. Remember, you need to place this line right underneath the $rss = new UniversalFeedCreator(); , or you'll waste precious processor cycles.

    You can also explicitly save the file with a command like this:

      echo $rss->saveFeed("RSS2.0", "index.xml");

    Dates

    Because, caching not withstanding, the feeds are usually produced dynamically, FeedCreator declares the channel/lastBuildDate element automatically at the time of creation. You can, of course, specify it explicitly, as you can with pubDate. FeedCreator allows the use of RFC 822 (Mon, 20 Jan 03 18:05:41 +0400), ISO 8601 (2003-01-20T18:05:41+04:00), and Unix (1043082341) time values.

    Namespaced modules

    This is the major drawback with the class. You can't, as of Version 1.71 at least, create a feed with modules in it. If you're set on doing that--perhaps with some groovy special in-house application in mind--you'll need to hack at the class's code. It is licensed under the GPL, so go right ahead.

    Creating RSS 2.0 with Ruby

    Since Version 1.8.2, Ruby has shipped with Kouhei Sutou's RSS parsing and creation library. At time of writing, however, Ruby has only reached 1.8.2.preview.3, and documentation is hard to come by. The only documentation for the new RSS classes is found at:

      http://www.cozmixng.org/~rwiki/?cmd=view;name=RSS+Parser%3A%3ATutorial.en

    in a potentially unreliable translation from the Japanese original.

    Having said that, the library does seem very complete indeed, with support for the parsing and writing of both RSS 1.0 and 2.0. At time of writing, the tutorial just mentioned was growing rapidly and being completed by the library's author. Ruby programmers should check the URL for changes.

    Serving RSS 2.0

    Although, or perhaps because, there is no official word within the specification regarding this, the growing standard for serving RSS 2.0 is with a MIME type of application/xml. Dave Winer prefers text/xml for the way that it causes the file to display itself nicely inside Internet Explorer. Using application/xml is more correct, but it causes browsers to download the file instead of displaying it. Really advanced users are looking at application/rss+xml, but currently no standard exists. It's up to you, but certainly, it should not be served with any other MIME type. text/plain is right out.


    DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware.

       · 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 3 hosted by Hostway