Woodstox : Verify Empty Element Content

Overview

This article demonstrates how to verify whether an element is empty or not using Woodstox StAX parser.

Create employee.xml as shown below.

Note that the element ‘address’ is empty.

Create TestVerifyEmptyElement class as shown below.

Note that start element is obtained by using the StAX API (see lines 20-26 below).

Verify that the ‘address’ element is empty using
XMLStreamReader2.isEmptyElement()
method (see line 22 below).

The output of the program demonstrating how to verify empty element is shown below:

Download Source Code for this Program

Leave a Comment