Reading xml with the dom parser in java is a lot of work, hard to read and very inflexible. In this example we will show how using the Groovy convenience class XMLParser to simplify parsing xml from a file.
Finding the path of the xml file to read using the Java 7 syntax, we will pass the file into the parse() method. The parser will return a groovy.util.Node and using Gpath expressions we can walk through the tree. Highlighting common operations the first assert gets the name of the root element, the second walks the dom to get the routID text contained in the node, the third statement validates that each stations value is contained in the list while the last finds the station with the attribute of one.