Java Mailing List Archive

http://www.gg3721.com/

Home » user.groovy »

[groovy-user] Accessing local text of a node with XmlSlurper

Kevan Stannard

2010-08-23

Replies: Find Java Web Hosting

Author LoginPost Reply
When accessing the text() of a node we get the node's text plus the text of all it's children.

For example, the following code prints 'HelloWorld'

def xml = '<root><span>Hello<span>World</span></span></root>'
def root = new XmlSlurper().parseText(xml)
println root.span.text()

I just want to access the 'Hello' part.

The following ticket describes this situation
http://jira.codehaus.org/browse/GROOVY-2115

I'm just looking for a workaround technique for now.

Thanks



©2008 gg3721.com - Jax Systems, LLC, U.S.A.