Details
Description
When using XmlParser we are experienceing different behaviour within Grails 1.2 than directly using Groovy 1.6.7. The issue manifests itself when accessing nested elements in a document.
example, this works fine from within GroovyConsole 1.6.7:
def XML = '''<channel> <item id="1"/> <item id="2"/> <item id="3"/> </channel>''' assert 3 == new XmlParser().parseText(XML).item.size() assert 3 == new XmlParser().parseText("<rss>$XML</rss>").channel.item.size()
Here is a test case that passed under Grails 1.1.1 but fails under 1.2:
class XMLUnitTests extends GroovyTestCase { def XML = ''' <channel> <item id="1"/> <item id="2"/> <item id="3"/> </channel> ''' void testOneLevel() { def records = new XmlParser().parseText(XML) assertEquals 3, records.item.size() } void testTwoLevels() { def records = new XmlParser().parseText("<rss>$XML</rss>") assertEquals 3, records.channel.item.size() } }