8.1 Parsing XML
In Groovy we can use the Java-based parsing approaches and tools we are already familiar with if we have some special need or reasons to depend on the older APIs or have legacy code that already uses them. If we have working Java code to parse XML documents, we can reuse those readily in Groovy. Groovy does not force us to duplicate our efforts.
If we’re creating new code to parse XML, though, we can benefit from the Groovy facilities.
On a recent project, I had to populate an application with data from some 400 XML documents. At first glance, that task was intimidating; the sheer volume of files to deal with was enough to dissuade me. After quickly browsing through several files, I decided to use Groovy to process the files, ...
Get Programming Groovy 2 now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.