« Return to Thread: XmlSlurper

Re: XmlSlurper

by HamletDRC :: Rate this Message:

Reply to Author | View in Thread

> 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@...


On Thu, Jul 2, 2009 at 4:20 PM, Edward
Sumerfield<esumerfd@...> wrote:
> 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


--
Hamlet D'Arcy

 « Return to Thread: XmlSlurper