How to find element by attribute value in GPath?

后端 未结 4 1419
故里飘歌
故里飘歌 2021-02-18 18:35

What is an alternative to this XPath //div[@id=\'foo\'] in GPath? In general, where I can find this documentation?

4条回答
  •  情深已故
    2021-02-18 18:51

    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.

提交回复
热议问题