Details
Description
I've borrowed some code from an earlier post to create a simple test case (http://stackoverflow.com/questions/2929186/weird-nodebuilder-and-gpath-behaviour-in-grails) here:
def builder = new NodeBuilder() def menu = builder.menu { header(title: "header 1") header(title: "header 2") } menu.header.each { println it.name }
The results between grails 1.2.1 and 1.3.1 differ.
1.2.1 prints:
header
header
1.3.1 prints:
[]
[]
1.2.1 prints what I expect to be the correct output, 1.3.1 does not.
Activity
- All
- Comments
- Work Log
- History
- Activity
- Git Commits
NodeBuilder is part of Groovy not Grails. Grails 1.2 ships with Groovy 1.6 whilst Grails 1.3 ships with Groovy 1.7. You'll need to raise a JIRA in the Groovy JIRA.
Nevertheless I checked verses the different Groovy versions (1.6 vs 1.7) and youR code prints
In both versions, so I don't see the problem. I think you need to use the name() method rather than a name property in which case it works the same across both versions: