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(); } } |