Is Streaming and Tree-Based XML parsers consumes similar amount of memory at the begining in JAVA



There are two main parsers to read an XML.



  1. Streaming parser - (eg : SAX, StAX)

  2. Tree-Based parser - (eg : DOM, AXIOM etc)


It is said the Streaming Parsers uses less memory than the tree based parsers. One thing to be noted is unlike tree-based parsers, Streaming parsers doesn't provide the entire XML tree to be navigated by the developer. In there, we can navigate based on the event. And after each event is handled, the data (xml content) that associated with that event can be discarded from the memory by the processor.


But, in both cases we must provide the entire XML content to the parsers. So, internally that parser must store that entire XML content in memory to navigate through each node. So, my argument is how is Streaming parsers consumes less memory than tree-based parsers?



  1. When it is started to read a XML, is both Streaming and Tree-Based parsers consumes similar amount of memory?

  2. What are the techniques that Streaming parsers use to consumes less memory than tree-based parsers?


References :



No comments:

Post a Comment