I'm very new to groovy so please excuse if its a silly question.
I'm parsing a XML file and fetching the fruit names to a list. My incomplete code snippet below.
....
....
def xmlOutput = proc.in.text
def lists = new XmlSlurper().parseText(xmlOutput)
def listOffruits = lists.fruits.entry.name
//Below is the fuit list for which I want to skip the loop
def myList = ["orange", "apple", "banana", "grapes"]
listOffruits.each(){
def fruitName = it.text()
//Not sure how on the logic
println "- found Fruit Name not on the list'${fruitName }'"
}
I want to check/compare if the fruit name is present in the list - "myList" , if present skip the loop or move on to next iterator ,if not continue with the loop.
I'm not sure how exactly to achieve it. Any suggestions pls. Thanks.