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.

Download javaxt-rss
Current Version: 1.2
Release Date: 2/14/2018
File Size: 35 KB
File Format: Zip
Includes: Jar File, Binaries, 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();
        }
    }

GeoRSS and W3C Geo Support

The javaxt-rss library can be used to parse location information published in standard Atom and RSS feeds. Location information can be expressed as points, lines, polygons, etc. and can be encoded using GeoRSS "where" tags or W3C "geo" tags.

Current Features

  • Supports W3C Basic Geometries
  • Supports GeoRSS Simple Geometries
    - georss:point
    - georss:line
    - georss:polygon
    - georss:box
  • Supports Common GML Geometries
    - gml:Point
    - gml:LineString
    - gml:Polygon
    - gml:Envelope
    - gml:box *
    - gml:MultiPoint *
    - gml:MultiLineString *
    - gml:MultiPolygon *
    * Not currently part of the GeoRSS Standard

Known Issues

  • GeoRSS Simple Geometries:
    - Does not support circles or elevation
  • GML Geometries with javaxt-gis:
    - Does not support coordinate triples
    - Does not handle the dimension or decimal attributes
    - Does not properly handle Polygons with inner polygons
    - Does not handle all GML Geometries
  • GML Geometries with JTS:
    - GML Boxes and Envelopes are improperly cast to
    com.vividsolutions.jts.geom.Geometry

To parse location information with javaxt-rss, you'll need a copy of javaxt-gis or JTS somewhere in your class path. This can be as as simple as dropping the "jts-1.11.jar" or "javaxt-gis.jar" in the same directory as your "javaxt-rss.jar" file. If a suitable library is found, you can serialize the location information into a "Geometry" object with the getLocation() method.

Dependencies

The javaxt-rss library has no dependencies. It will compile and build without any other library. Optional dependencies include:

Maven Support

If you're a Maven user, you can configure your pom.xml to pull releases directly from this site. To add javaxt-rss to your project, simply add this site to your list of repositories and add a dependency. XML snippits below. See the downloads page for more information.
Add Maven Repository
  <repositories>
    <repository>
      <id>javaxt.com</id>
      <url>https://www.javaxt.com/maven</url>
    </repository>
  </repositories>
Add Maven Dependency
  <dependencies>
    <dependency>
      <groupId>javaxt</groupId>
      <artifactId>javaxt-rss</artifactId>
      <version>1.2</version>
    </dependency>
  </dependencies>