GPath is a path expression language integrated into Groovy which allows parts of nested structured data to be identified. In this sense, it has similar aims and scope as XPath does for XML. The two main places where you use GPath expressions is when dealing with nested POJOs or when dealing with XML.
As an example, you can specify a path to an object or element of interest:
a.b.c -> for XML, yields all the <c> elements inside <b> inside <a>
a.b.c -> all POJOs, yields the <c> properties for all the <b> properties of <a> (sort of like a.getB().getC() in JavaBeans)
For XML, you can also specify attributes, e.g.:
a["@href"] -> the href attribute of all the a elements
a.'@href' -> an alternative way of expressing this
a.@href -> an alternative way of expressing this when using
The best example of GPath for xml is test-new/groovy/util/XmlSlurperTest.groovy.
If the element is a father node,it will print all children's text.
Here is a two line example of how to get a list of all the links to .xml files listed on a web page. The Neko parser is used to parse non-well formed html. It no longer ships as part of the standard Groovy distribution but can be downloaded and dropped into the lib directory of your Groovy distribution. You'll need to also add a copy of xercesImpl.jar to the groovy lib directory.
See also: Processing XML