What is an alternative to this XPath //div[@id='foo']
in GPath? In general, where I can find this documentation?
Here is the corresponding snippet:
def node = new XmlSlurper().parseText(...) def foo = node.depthFirst().findAll { it.name() == 'div' && it.@id == 'foo'}
A few other links you may want to read:
The previous poster gave you all that's required: Assuming your document has been slurped into xml
, you want
def foo = xml.path.to.div.find{it.@id == 'foo'}
to find a single result. Or findAll
to find all results.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With