Reading RSS feeds using groovy

def channel=new XmlParser().parse(url).channel[0]
println channel.title.text()
println channel.link.text()
println channel.description.text()
println ‘\nStories:\n———‘
def items=channel.item
for(item in items){
println item.title.text()
println item.link.text()
printlnHeres a  item.description.text()
println’——-‘
}

Here is a small groovy script to read from any RSS feed.

def url='http://feeds.dzone.com/dzone/frontpage'

def channel=new XmlParser().parse(url).channel[0]

println channel.title.text()

println channel.link.text()

println channel.description.text()

println '\nStories:\n---------'

def items=channel.item

for(item in items){

println item.title.text()

println item.link.text()

println item.description.text()

println'-------'

}

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: