A few days I was looking for some library to parsing RSS feeds in Java mainly for Android purpose. For me it was quite obvious that I will pick up library called ROME because of I have still a pretty good feeling about it from previous projects. Below you can find my piece of code which is very similar to this one on ROME website.
URL url = new URL("https://www.centralbank.ie/Pages/RSSFeedDisplay.aspx?FeedID=20"); SyndFeedInput input = new SyndFeedInput(); SyndFeed feed = input.build(new XmlReader(url)); List entries = feed.getEntries(); logger.info("Size : " + entries.size()); Iterator iterator = entries.iterator(); while (iterator.hasNext()) { SyndEntry entry = (SyndEntry) iterator.next(); logger.info("Entry : " + entry.getTitle() + " " + entry.getAuthor() + " " + entry.getLink()); }
If you will use official ROME library [1] on Android you will be faced with this error :
ERROR/AndroidRuntime(263): java.lang.NoClassDefFoundError: [Ljava.beans.PropertyDescriptor;
This error occurred due to lack of libraries on Android platform related to java.beans package. Fortunately there is a way to parse this RSS on Android platform properly. Only what you need to do is download fork of ROME library called AndroidROMEFeedReader [2] and apply jdom-1.1.1-android-fork.jar and android-rome-feed-reader-1.0.0.jar to your project in Android Studio. From this moment you will be able to fetch and parse RSS without including java.beans package to your project.
Reference: [1] ROME [2] GitHub AndroidROMEFeedReader [3] Docs Oracle Java Beans
ROME Parsing RSS
2015-08-30T12:07:00+01:00
GarciaPL
Android|Java|