Skip to content
Advertisement

Understanding XMLStreamReader and START_ELEMENT

Consider the following XML file:

JavaScript

Why am I not getting a START_ELEMENT event when using XMLStreamReader. Code is (lifted from):

JavaScript

Output on my side:

JavaScript

Ref:

JavaScript

Advertisement

Answer

Turns out the documentation has it described:

An XMLStreamReader instance is created with an initial event type START_DOCUMENT.

So code should instead be:

JavaScript

The loop is easier to write using XMLEventReader:

JavaScript
User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement