Aalto StAX Parsing: Error Handling


This article demonstrates how to handle parser related errors using Aalto StAX parser.

Create employee.xml as shown below.

Note that the ‘salary’ element is not properly closed (see line 4 below).

Create TestErrorHandling as shown below.

Catch the
(see line 39 below)) which is short for ‘Well-Formedness Constraint violation’ exception.

The output of the program demonstrating that parsing related exception is caught is shown below (see lines 6-7 below).

Download Source Code for this Program

Leave a Comment