Is there a way to have XmlSlurper get arbitrary elements through a variable? e.g. so I can do something like input file:
<file>
<record name="some record" />
<record name="some other record" />
</file>
def xml = new XmlSlurper().parse(inputFile)
String foo = "record"
return xml.{foo}.size()
I've tried using {} and ${} and () how do I escape variables like that? Or isn't there a way? and is it possible to use results from closures as the arguments as well? So I could do something like
String foo = file.record
int numRecords = xml.{foo.find(/.\w+$/)}