Parse selected RSS feeds


#1

Hi guys,

Im totally useless at coding, just trying to learn from examples on the internet,

def url = "http://www.reddit.com/r/todayilearned/.rss"
def rss = new XmlSlurper().parse(url)

output:
${(rss.channel.item.title)}

Right now it is outputting all the stories, how do I select the first story or how to select one story?


(Jason Mok) #2

rss.channel.item.title.find{ it.toString().contains(“kangaroos”) }

try reading some groovy examples:
http://groovy.codehaus.org/JN1035-Maps


#3

Hi Jason,

Thanks for your quick reply. But this function will just search by keyword, how do I select say only the second item.title?