Issue Details (XML | Word | Printable)

Key: GROOVY-2233
Type: Improvement Improvement
Status: Closed Closed
Resolution: Fixed
Priority: Minor Minor
Assignee: Paul King
Reporter: Marshall Schor
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
groovy

GPath: allow attribute reference using unquoted selectors in XmlParser Nodes, making it consistent with XmlSlurper

Created: 22/Oct/07 08:46 AM   Updated: 13/Nov/07 06:58 PM
Component/s: None
Affects Version/s: None
Fix Version/s: 1.1-rc-2

Time Tracking:
Not Specified

Environment: groovy 1.1 rc-1


 Description  « Hide
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".



 All   Comments   Work Log   Change History      Sort Order: Ascending order - Click to sort in descending order
Guillaume Laforge added a comment - 22/Oct/07 09:45 AM
Paul, if you fancy it, otherwise, feel free to un-assign it.