Wednesday, August 6, 2014

Groovy and XML parsing

Yo!

Say we count books in genres in a book shop that has it's data in big xml file:

Let's use Groovy

def xml = new XmlSlurper().parse("/home/user/bigXML.xml")
xml.genres.genre.each {
    println "Genre " + it.'@genre_name' + " has this many books: " + it.books.book.size()
}


src
http://groovy.codehaus.org/Reading+XML+using+Groovy%27s+XmlParser

IDEA appeared to be a nice IDE for Groovy

No comments:

Post a Comment