Hm. First, I tried, like Michael, to use the built-in xml. But it looks like groovy can properly treat them like a GString.
So, I managed to get the work to work differently: Templates
def xml = new XmlSlurper().parse("test.xml")
def engine = new groovy.text.SimpleTemplateEngine()
def value = xml.em."@value".each { // iterate over attributes
println(engine.createTemplate(it.text()).make().toString())
}
test.xml
<root>
<em value="5"></em>
<em value='"5"'></em>
<em value='${new Date()}'></em>
<em value='${ 5 + 4 }'></em>
</root>
Output
5
"5"
Wed Feb 26 23:01:02 MSK 2014
9
groovy , ", .