History | Log In     View a printable version of the current page.  
Issue Details (XML | Word | Printable)

Key: GROOVY-2115
Type: New Feature New Feature
Status: Open Open
Priority: Major Major
Assignee: John Wilson
Reporter: Ken Sayers
Votes: 0
Watchers: 0
Operations

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

text() method on NodeChild with XmlSlurper returns composite. Need just local text.

Created: 11/Sep/07 08:34 PM   Updated: 13/Feb/08 05:22 AM
Component/s: XML Processing
Affects Version/s: None
Fix Version/s: None

Time Tracking:
Not Specified

Environment: windows xp on jdk 1.4.2


 Description  « Hide
I am trying to use XmlSlurper to process and xml with nested elements with text in them. I need to get the text from just one level at a time but the text() method returns all text for all childrend and I can't see anything that would bring back just the local.

Here is a sample from the console:

groovy> def model = new XmlSlurper().parseText('<aModel><aParent name="bubba">text<aChild>child text</aChild></aParent></aModel>')

groovy> model.aParent[0].text()

groovy>

groovy>

Result: "textchild text"



 All   Comments   Work Log   Change History      Sort Order: Ascending order - Click to sort in descending order
Paul King - 12/Feb/08 05:26 PM
John, assigning to you if for nothing else for comment. Given your proposed new method(s) to XmlSlurper it kind of makes sense to try to tackle this at the same time I think. Just assign back (or leave unassigned) if you have no time (though any suggestions would be welcome) or provide a comment if you think the feature request is not warranted and can be done by other means.

John Wilson - 13/Feb/08 05:22 AM
This is not a bug - text() does what it is designed to do which is to give you all the text in the element

However there is a need for an additional mechanism to let you handle mixed content as in the example provided.

I'm working on this