Java Mailing List Archive

http://www.gg3721.com/

Home » user.groovy »

Re: [groovy-user] XmlSlurper

HamletDRC

2009-07-03

Replies: Find Java Web Hosting

Author LoginPost Reply
> Is there a simple way to copy a node from the XmlSlurper into a groovy bean?

Does the groovy bean have to have a specific type? Like, do you have
an existing domain object that you're trying to get XML into?

If not, and you can handle dynamic types, then you could write a
generic algorithm that walks an XML tree and constructs a closure-map
of the contents of your XML. Our you could write a class that wraps
the XmlSlurper and uses invokeMethod to translate methods calls on
your object into method calls on the wrapped XmlSlurper instance.
That's be kinda neat to define a more OO friendly API over XmlSlurper
than the GPath/grep/findall stuff provides. I can never remember the
correct syntax for that stuff.

--
Hamlet D'Arcy
hamletdrc@(protected)


On Thu, Jul 2, 2009 at 4:20 PM, Edward
Sumerfield<esumerfd@(protected):
> Is there a simple way to copy a node from the XmlSlurper into a groovy bean?
>
> Ed
>
>

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

  http://xircles.codehaus.org/manage_email


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