1. overview of Different XML parser Comparison
This post is about different Java XML parser comparative studies, whether you choose push parser or pull parser and in which situation. When you get the opportunity to parse any XML, first of all, you should know a few things:
- how much byte size of XML content and node?
- how frequently you want to parse XML?
- whether you want to write or read?
- how complex structure of your XML has?
- how much memory do you have in the application server?
You can better judge and choose the parser if you know the basic things about your XML structure and all.
2. Pull parser Vs Push parser
In this section, high level there are two different parser pull parser vs push parser. pull means, always return something ( XML Infoset). When talking about pull, it’s always programmer-friendly, and easy to debug, control in application code.
push means, no return in method, you pass the object reference code-base, the parser controls the application thread. a little bit difficult to debug, not programmer friendly.
2. Advantage of Pull Parser over Push:
There are different XML parsers you have and you have to choose one of them to proceed with your work.
- With pull parsing, the client controls the application thread and can call methods on the parser when needed.
- With push processing, the parser controls the application thread, and the client can only accept invocations from the parser.
- Pull parsing libraries can be much smaller and client code to interact with those libraries much simpler than with push libraries, even for more complex documents.
- Pull clients can read multiple documents at one time with a single thread.
StAXpull parser can filter XML documents , in such a way elements unnecessary to the client can be ignored, and it can support XML views of non-XML data.
3. XML Parser API Feature Summary
The following is the summary of features of different XML parsers. The intent is parsing your XML with business use-case, philosophy of all the different parser are different to some extent.
|API Type||In memory tree||Push, streaming||Pull, streaming,||XSLT Rule|
|Ease of Use,||High||Medium||High||Medium|
|CPU and Memory Efficiency||Varies||Good||Good||Varies|
Your comments are welcome to improve this post pull parser vs push parser. Happy Learning 🙂