Once we are done with the current event, we move to the next one and continue.The events can be for example the start of element, the end of element or characters data.You could of course run a reformatter on the generated file but that might add a lot of processing time for large files. One clever idea is to wrap the writer in a proxy but if you don’t need internally runs on top of SAX but that doesn’t need to concern us. formatting XML with line breaks and perhaps indentation.
The older APIs, Simple API for XML APIs (SAX parser) and Document Object Model APIs (W3C DOM), are much better known but suffer from significant downsides.
XML is widely used technology to transport or store data.
Java Provides various API’s for processing XML; for example DOM, SAX, St AX, JAXB.
In my opinion PULL interface is more straightforward to use and leads to smaller and more readable code responsible for handling of events.
XMLStream Reader takes care of most tasks related with parsing of XML documents like expanding entity references, unescaping special characters or handling XML namespaces.