Java Implementation

The Java implementation is composed of the following source files:

  • XMLToCSVSimple.java: the main routine for the Java application

  • CSVRowWriter.java: a class with write and formatRow methods

  • SAXErrorHandler.java: a class that handles exceptions while parsing the input XML document

The formatRow method is not very relevant to the main thrust of the book, so I won't discuss it further here other than to make one comment. The formatRow method uses only a comma as a field delimiter and always encloses fields with quotes. In Chapter 7 we'll develop a more flexible approach.

Get Using XML with Legacy Business Applications 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.