Overview
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
WFCException
(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).