Different XML parser Comparison

Connect with

different XML parser comparison Pull parser vs push parserDifferent XML parser Comparison Java, pull parser vs push parser comparison. Parsers : DOM parser, SAX parser, StAX parser, TrAX parser.

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.
  • A StAX pull 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.

Feature DOM SAX StAX TrAX
API TypeIn memory treePush, streamingPull, streaming,XSLT Rule
Ease of Use,HighMediumHighMedium
XPath CapabilityYesNoNoYes
CPU and Memory EfficiencyVariesGoodGoodVaries
Read XMLYesYesYesYes
Write XMLYesNoYesYes
CRUDYesNoNoNO
Forward OnlyNoYesYesNo

4. Related Post on DOM SAX Parsers

In order to understand the difference between DOM and SAX, you have to understand each one of the parsers. For this you can visit.

5. Reference

Oracle Java Official site

Your comments are welcome to improve this post pull parser vs push parser. Happy Learning 🙂


Connect with

1 thought on “Different XML parser Comparison”

  1. Pingback: rakhi

Leave a Comment

Your email address will not be published. Required fields are marked *