OPML to HMTL using Informa

I’ve been having a few email discussions with a few of the blog readers about how I manage my blogroll and I decided to blog about it. Before I went out and purchased a copy of FeedDemon, a great RSS/ATOM feed reader, I had written my own crude feed reader. My feed reader used Informa for feed consumption and parsing and used a local MySQL database to keep track of my feeds subscription. Upon startup, the simple web application would load a list of my subscribed feeds from the database, parse them using Informa and save them locally. Worked well enough and let me learn more about Informa, which is really a very good RSS library for Java.

Now that I use FeedDemon, I output the blogs I read as an OPML file and then use Informa to create my HTML blogroll. Here’s a little code snippet on how I use Informa’s OPML support to parse my OPML file and iterate through the file to create the HTML that’s included in my blog. I also stole Don Park’s imageless RSS feed icon CSS to format my blogroll. Thanks Don – Great idea.

        try {
            Collection feeds = OPMLParser.parse("file:///C:/projects/opml2html/data/blogs.opml");
            sb.append("<ul class='navlist'>");

            Iterator it = feeds.iterator();
            while (it.hasNext()) {
                FeedIF feed = (FeedIF) it.next();
                sb.append("<li><a href=");
                sb.append(feed.getSite().toExternalForm());
                sb.append(">");
                sb.append(feed.getTitle());
                sb.append("</a>  <a href=");
                sb.append(feed.getLocation().toExternalForm());
                sb.append(" class='feedIconStyle'>XML</A>n");
            }
        } catch (IOException e) {
            //do something useful
        }

Informa is a great collaboration by the authors of HotSheet and Risotto, two independent Java/RSS efforts out in the market. If you have a need to parse RSS and display via. JSP’s, you need to check out the RSS JSP tag library and RSS-desk projects that are based on Informa.

1 thought on “OPML to HMTL using Informa

  1. Pingback: Vinny Carpenter’s blog » Blog Archive » OPML support in Java - Missing in Action

Comments are closed.