Searching in XML with GPath
When using XmlSlurper
or XmlParser
with Groovy (see the Reading XML using XmlSlurper and Reading XML using XmlParser recipes), the returned parsed result can be queried using GPath. GPath is a way to navigate nested data structures in Groovy. Sometimes GPath is called an expression language integrated into Groovy; but, in fact, GPath does not have a separate compiler or interpreter, it's just the way Groovy language and core classes are designed to make data structure navigation and modification concise and easy-to-read.
GPath, in certain ways, is similar to XPath (http://www.w3.org/TR/xpath/) that is used for querying XML data. The main difference is that it uses dots instead of slashes to navigate the XML hierarchy and it can be used for navigating the hierarchy of objects (Plain Old Java Objects (POJOs) and Plain Old Groovy Objects (POGOs) respectively).
The GPath syntax closely resembles E4X (ECMAScript for XML), which is an ECMAScript extension for accessing...