Search code examples
grailsgroovyrssfeed

check rss feed is down using groovy Xmlparser


I wants to put condition to check rss feed is down or up.

SAMPLE CODE

def url= 'http://'+
'www.groovyblogs.org/feed/rss'
def rss = new XmlParser().parse(url)
rss.channel.item.title[0..9]*.text()

How do i check whether www.groovyblogs.org/feed/rss is up or down. I want to handle something when feed is down.

Thanks in Advance


Solution

  • I want to handle something when feed is down.

    You can wrap the above code block in try and do the error handling in catch.

    If you want to check beforehand that if url is working or not Testing URLs in groovy should help.