JavaXT

RSS Parser

The javaxt-rss library is a simple, lightweight, open source RSS parser. It is used to parse both Atom and RSS feeds and extract common attributes including title, author, date, etc.

Current Version: 1.1.0
Release Date: 12/30/2011
File Size: 26 KB
File Format: Zip
Includes: Jar File, Source Code, and Documentation

Key Features

  • Basic Atom 1.0 and RSS 2.0 Support
  • Normalizes Tag Names to Identify Common Attributes
  • Automatically Serializes Dates and URLs to Native Java Types
  • GeoRSS and W3C Geo Support

Basic Usage

Here's a simple example of how to parse an RSS feed using the javaxt-rss library.
Please refer to the JavaDocs for a complete list of class and methods.

      //Download an RSS Feed and serialize it to an org.w3c.dom.Document. Note that in this 
      //example we are using the javaxt-core library but you can use whatever you want.
        String url = "http://feeds.guardian.co.uk/theguardian/rss";
        org.w3c.dom.Document xml = new javaxt.http.Request(url).getResponse().getXML();


      //Once we have an XML DOM Document, instantiate the RSS parser and loop through  
      //individual feeds. Usually there's only one feed or channel per document.
        for (javaxt.rss.Feed feed : new javaxt.rss.Parser(xml).getFeeds()){


          //Print basic information about the RSS feed
            System.out.println(feed.getTitle());
            System.out.println(feed.getDescription());
            System.out.println("Date:\t" + feed.getLastUpdate());
            System.out.println();


          //Iterate through individual items in the feed
            for (javaxt.rss.Item item : feed.getItems()){
                System.out.println("Title:\t" + item.getTitle());
                System.out.println("Date:\t" + item.getDate());
                System.out.println("Link:\t" + item.getLink());
                System.out.println("Location:\t" + item.getLocation());
                System.out.println("Media:");
                for (javaxt.rss.Media media : item.getMedia()){
                    System.out.println("Type:\t" + media.getType());
                    System.out.println("Link:\t" + media.getLink());
                }
                System.out.println();
            }
        }
    

Revision History

Version 1.0 (11/16/2009) Initial Release
Version 1.1 (12/30/2011) Removed dependencies on javaxt-core and javaxt-gis