Download NetBeans!

20080724 Thursday July 24, 2008

Parsing XML with Groovy

The web service looked at yesterday returns a Shakespeare speech in XML format based on the search string that is sent via Groovy from a Swing form created in Matisse. Groovy isn't only useful in interacting with the web service—parsing the returned XML is also a trivial activity with Groovy:

As shown yesterday, the Groovy method shown above is called from the button in the form, that you see deployed in the screenshot above. On the return of the XML, Groovy takes a tiny number of lines to break up the payload and then (without the "return" statement being necessary, as pointed out in the comments yesterday by Alex Tkachman) is returned to the Swing form.

Jul 24 2008, 01:49:46 PM PDT Permalink