JavaXT
|
|||
RSS ParserThe 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 UsageHere's a simple example of how to parse an RSS feed using the javaxt-rss library. //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 SupportThe 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.
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. DependenciesThe javaxt-rss library has no dependencies. It will compile and build without any other library. Optional dependencies include:
Maven SupportIf 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> |