How to find all XML elements by tag name in Groovy? -
How to find all XML elements by tag name in Groovy? -
how can find elements in xml tag name in groovy (gpath)?
i need find car
elements in document:
<records> <first> <car><id>378932<id></car> </first> <second> <foo> <car><name>audi</name></car> </foo> </second> </records>
this tried , failed:
def xml = new xmlslurper().parse(file) assert xml.car.size() == 2
this how works:
def xml = new xmlslurper().parse(file) def cars = xml.depthfirst().findall { it.name() == 'car' } assert cars.size() == 2
xml groovy
Comments
Post a Comment