I am using:
def idx=parent.item.children().indexOf(myElement)
if (idx+1<parent.children().size()) {
def message=parent.children()[idx+1]
println message.text()
}
开发者_运维百科
To find the element message which is next after myelement in the parent.
However, it seems there must be a Groovier way, no?
Thank you Misha
Assuming you're trying to find all after the first one you would do this:
def messages = parent.item.children().findAll { child -> child.name() == myElement }
messages[1..-1].each { println it }
If you wanted to just print out all messages that matched myElement
parent.item.children().findAll { child -> child.name() == myElement }.each { println it }
精彩评论