How to read Atom and RSS feeds using Scala

In case you ever need to read an Atom or RSS feed using Scala, this example code shows how to use the Java ROME library in your Scala code:

import com.rometools.rome.feed.synd.{SyndFeed}
import scala.collection.JavaConverters._

object AtomAndRssReader extends App {

    // NOTE: code can throw exceptions
    val feedUrl = new URL("")
    val input = new SyndFeedInput
    val feed: SyndFeed = XmlReader(feedUrl))

    // `feed.getEntries` has type `java.util.List[SyndEntry]`
    val entries = asScalaBuffer(feed.getEntries).toVector

    for (entry <- entries) {
        println("Title: " + entry.getTitle)
        println("URI:   " + entry.getUri)
        println("Date:  " + entry.getUpdatedDate)

        // java.util.List[SyndLink]
        val links = asScalaBuffer(entry.getLinks).toVector
        for (link <- links) {
            println("Link: " + link.getHref)

        val contents = asScalaBuffer(entry.getContents).toVector
        for (content <- contents) {
            println("Content: " + content.getValue)

        val categories = asScalaBuffer(entry.getCategories).toVector
        for (category <- categories) {
            println("Category: " + category.getName)




A few notes:

  • The code uses Scala’s JavaConverters class to convert the java.util.List instances into something more usable
  • You need to add the Rome dependency to your build.sbt file ("com.rometools" % "rome" % "1.8.1")
  • Of course the ROME library does all the heavy lifting; I just show how to use it in Scala, in particular with the JavaConverters class

The output

Here’s an abridged version of what the output from this code looks like today:

Title: Episode 820: P Is For Phosphorus 
Date:  null
Content: <img src='' /><p>Phosphate is a crucial element, for farming, and for life ...

Title: The 10 Events You Need To Know To Understand The Almost-Firing Of Robert Mueller
Date:  null
Content: <img src='' /><p>Everything about this story revolves around obstruction of justice ...

Note that the Date output is null. I haven’t looked into that yet — it’s not important for my needs — but as you can see, the rest of the output looks just fine, and the code works as intended.