Details
-
Type:
Improvement
-
Status:
Closed
-
Priority:
Minor
-
Resolution: Fixed
-
Affects Version/s: None
-
Fix Version/s: 1.1-rc-2
-
Component/s: None
-
Labels:None
-
Environment:groovy 1.1 rc-1
-
Number of attachments :
Description
The suggested way to access XML attributes from the results produced by XmlParser is to use the form x.'@attrName' . Note the quotes around the attribute name.
For XmlSlurper style of GPath, you can leave off the quotes, and write x.@attrName
This doesn't appear to be supported in the XmlParse style. The Groovy in Action book has a table (Table 12.4) on page 410-411, which shows
these variations and restrictions.
The form "x.@name" is also used, in general, in Groovy, to specify direct field access, see Groovy in Action on page 203, section titled
"Field access with .@".
Somehow, it appears, that for XmlSlurper results, you can use the ".@name" form to access an attribute.
It would be nice if the ".@name" form (where you don't have to "quote" the @name) worked also for XmlParse result "Nodes".
Paul, if you fancy it, otherwise, feel free to un-assign it.