Thursday Jul 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.

About

Geertjan Wielenga (@geertjanw) is a Principal Product Manager in the Oracle Developer Tools group living & working in Amsterdam. He is a Java technology enthusiast, evangelist, trainer, speaker, and writer. He blogs here daily.

The focus of this blog is mostly on NetBeans (a development tool primarily for Java programmers), with an occasional reference to NetBeans, and sometimes diverging to topics relating to NetBeans. And then there are days when NetBeans is mentioned, just for a change.

Search

Archives
« July 2008 »
SunMonTueWedThuFriSat
  
4
5
6
11
12
13
14
17
26
30
  
       
Today