Overview
Aalto provides a feature to peek into the next XML element from the current XML element. This is achieved by using
XMLEventReader.peek()
method.
Note that according JSR-173 specification,
XmlEventReader.peek()
method returns the next element but does not take it off the stream.
This sample program demonstrates how to peek into the next XML element.
Create employee.xml as shown below.
Create TestPeek as shown below.
Use
XMLEvent
to get the start element (see line 27-39 below). Print the contents of start element (see line 28 below).
Once the start element is obtained then use
XmlEventReader.peek()
to peek into the next element which is the character text(see line 31 below). Print the contents of peek element (see line 35 below).
The output of the program demonstrating peek functionality using Aalto is shown below.