Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
1.1-beta-2
-
None
-
Mac OS X, java 1.4-1.5
Description
def xml="""
<doc>
<name>My Doc Name</name>
<description>this is my doc</description>
</doc>
"""
def p = new XmlParser()
def doc = p.parseText(xml)
def desc = doc.description[0].text()
def name = doc.name[0].text() //exception
groovy.lang.MissingMethodException: No signature of method: java.lang.String.text() is applicable for argument types: () values: {}
Obviously the groovy.util.Node class' 'name' property is obscuring the element.
I had to resort to this to get the value for the name element:
def names = doc.directChildren.grep
{ node-> node.name=="name" }def name=nms[0].text()
It seems like this conflict would happen for any elements with the same name as properties of the Node class.