advertisement
Premier Club Log In/Registration
  Include Code  Search Tips
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   SKILLBUILDING  |   TIP BANK  |   SOURCEBANK  |   FORUMS  |   NEWSLETTERS
Browse DevX
Rss Feed Test
Partners & Affiliates
advertisement
advertisement
Average Rating: 5/5 | Rate this item | 1 user has rated this item.
 Print Print
 
Java Package Processes All RSS Formats
Several Java packages work with RSS. Some can read certain formats, while others can write them as well. The class this article features reads all known RSS formats and outputs the converted data in the 2.0 format. 

advertisement
SS (Real Simple Syndication) is a flexible and efficient format for exchanging structured, dynamically changing data, such as news headlines, blogs, job vacancies, new projects, recent wiki changes, etc. You might not have noticed it yet, but as soon as you get tuned in, you'll discover it is ubiquitous.

You'll find several scattered Java packages that work with RSS. Some can read certain formats, while others can write them as well. The class I feature in this article, com.myjavatools.xml.Rss, reads all known RSS formats (from version 0.90 to 2.0) and outputs all the converted data in the 2.0 format.

You can instantiate com.myjavatools.xml.Rss from any RSS feed, regardless of version. The class gives access to all the RSS elements, and you also can create new RSS containers, add or change the contents, and write RSS data to an output stream. However, it doesn't offer any syndication features, so no filtration or selection.

A Brief History of RSS
Userland developed RSS in 1997. Netscape immediately adopted it, and Userland and Netscape continued working on RSS formats in parallel. RSS-DEV working group and W3C's RDF (Resource Description Framework group) also participated in developing RSS standards. For Userland, RSS stood for Rich Site Summary; for Netscape, it was RDF Site Summary. Eventually, other explanations for RSS emerged: Remote Site Syndication and Really Simple Syndication. The last one is the most popular since it indicates the main function of the RSS format: facilitating content feed syndication.

Essentially, an RSS document contains one <channel> element, which may have a title, a description, and a link, as well as an <image> element and a certain amount of <item> and <textInput> elements. All these elements have at least a title, and <item> typically also has a description and a link to a resource. If only one RSS format (such as XML) existed, that would be the end of the story. Unfortunately, history had other ideas. The following is an example of the Netscape version (0.90) for a document that features an article and tip I wrote for DevX:

<rdf:RDF
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns="http://my.netscape.com/rdf/simple/0.9/">
  <channel>
    <title>devx.com</title>
    <link>http://www.devx.com</link>
    <description>DevX.com--the know-how behind application development.</description>
    <image>
      <title></title>
      <url>http://www.devx.com/assets/devx/7819.gif</url>
      <link>http://www.devx.com/</link>
    </image>
    <item>
      <title>Practical XML for Java Programs</title>
      <link>http://www.devx.com/Java/Article/16571/0</link>
    </item>
    <item>
      <title>Get Nasdaq Quotes Online in Your Java Program</title>
      <link>http://www.devx.com/tips/Tip/14965</link>
    </item>
  </channel>
</rdf:RDF>

Note the absence of item descriptions.

The next Netscape version, 0.91, which was introduced in July 1999, dropped namespaces and added descriptions to items. Look at how the same example code as above appears in this version:

<rss version="0.91">
  <channel>
    <title>devx.com</title>
    <link>http://www.devx.com/</link>
    <description>DevX.com&#mdash;the know-how behind application development.</description>
    <language>en-us</language>
    <item>
      <title>Practical XML for Java Programs</title>
      <link>http://www.devx.com/Java/Article/16571/0</link>
      <description>When dealing with XML, you need a convenient 
representation of the XML data in memory. This article offers Java programmers 
a solution to achieve this goal: an easy-to-use package for handling XML data in Java.</description>
    </item>
      <title>Get Nasdaq Quotes Online in Your Java Program</title>
      <link>http://www.devx.com/tips/Tip/14965</link>
  </channel>
</rss>

Versions 0.92 through 0.94 added various elements to the format, such as webMaster, managingEditor, expirationDate, skipHours, rating, and language. In 2000, an independent group, RSS-DEV, published version 1.0, which was based on 0.90. Version 1.0 turned out to be obscure and unreadable since it widely used the XML namespaces that were popular during those opulent times.

In 2002, Userland published version 2.0, based on 0.92-0.94. Version 2.0 actually had three slightly different flavors:

  • September 2002: <rating> element dropped
  • November 2002: <skipHours> changed from the questionable 1-24 range to 0-23
  • January 2003: <rating> element returns

Forgetting these minor discrepancies, take a look at an example of 2.0:

<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>devx.com</title>
    <link>http://www.devx.com/</link>
    <description>DevX.com&#mdash;the know-how behind application development.</description>
    <language>en-us</language>
    <item>
      <title>Practical XML for Java Programs</title>
      <link>http://www.devx.com/Java/Article/16571/0</link>
      <description>When dealing with XML, you need a convenient representation
 of the XML data in memory. This article offers Java programmers a solution
 to achieve this goal: an easy-to-use package for handling XML data in Java.</description>
      <dc:creator>Vlad Patryshev</dc:creator>
      <dc:date>2003-07-25</dc:date>
    </item>
      <title>Get Nasdaq Quotes Online in Your Java Program</title>
      <link>http://www.devx.com/tips/Tip/14965</link>
      <description>Get Nasdaq quotes online in your Java program.</description>
      <dc:creator>Vlad Patryshev</dc:creator>
      <dc:date>2001-11-09</dc:date>
  </channel>
</rss>

This link to RSS.NET contains a comparison chart of all RSS versions.

Page 1 of 2
advertisement
  Next Page: RSS in Java
Page 1: IntroductionPage 2: RSS in Java
advertisement
Advertising Info  |   Member Services  |   Permissions  |   Contact Us  |   Help  |   Feedback  |   Site Map  |   Network Map  |   About


JupiterOnlineMedia

internet.comearthweb.comDevx.commediabistro.comGraphics.com

Search:

Jupitermedia Corporation has two divisions: Jupiterimages and JupiterOnlineMedia

Jupitermedia Corporate Info


Legal Notices, Licensing, Reprints, & Permissions, Privacy Policy.

Advertise | Newsletters | Tech Jobs | Shopping | E-mail Offers

Solutions
Whitepapers and eBooks
Microsoft Article: HyperV-The Killer Feature in WinServer ‘08
Avaya Article: How to Feed Data into the Avaya Event Processor
Microsoft Article: Install What You Need with Win Server ‘08
HP eBook: Putting the Green into IT
Whitepaper: HP Integrated Citrix XenServer for HP ProLiant Servers
Intel Go Parallel Portal: Interview with C++ Guru Herb Sutter, Part 1
Intel Go Parallel Portal: Interview with C++ Guru Herb Sutter, Part 2--The Future of Concurrency
Avaya Article: Setting Up a SIP A/S Development Environment
IBM Article: How Cool Is Your Data Center?
Microsoft Article: Managing Virtual Machines with Microsoft System Center
HP eBook: Storage Networking , Part 1
Microsoft Article: Solving Data Center Complexity with Microsoft System Center Configuration Manager 2007
MORE WHITEPAPERS, EBOOKS, AND ARTICLES
Webcasts
Intel Video: Are Multi-core Processors Here to Stay?
On-Demand Webcast: Five Virtualization Trends to Watch
HP Video: Page Cost Calculator
Intel Video: APIs for Parallel Programming
HP Webcast: Storage Is Changing Fast - Be Ready or Be Left Behind
Microsoft Silverlight Video: Creating Fading Controls with Expression Design and Expression Blend 2
MORE WEBCASTS, PODCASTS, AND VIDEOS
Downloads and eKits
Sun Download: Solaris 8 Migration Assistant
Sybase Download: SQL Anywhere Developer Edition
Red Gate Download: SQL Backup Pro and free DBA Best Practices eBook
Red Gate Download: SQL Compare Pro 6
Iron Speed Designer Application Generator
MORE DOWNLOADS, EKITS, AND FREE TRIALS
Tutorials and Demos
How-to-Article: Preparing for Hyper-Threading Technology and Dual Core Technology
eTouch PDF: Conquering the Tyranny of E-Mail and Word Processors
IBM Article: Collaborating in the High-Performance Workplace
HP Demo: StorageWorks EVA4400
Microsoft How-to Article: Get Going with Silverlight and Windows Live
MORE TUTORIALS, DEMOS AND STEP-BY-STEP GUIDES