Meaningless Drivel is fun!*
The moose likes XML and Related Technologies and the fly likes Push parsing and Pull parsing  of Streaming API. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "Push parsing and Pull parsing  of Streaming API." Watch "Push parsing and Pull parsing  of Streaming API." New topic

Push parsing and Pull parsing of Streaming API.

Edward Chen
Ranch Hand

Joined: Dec 23, 2003
Posts: 798
I still confuse the Push parsing and Pull parsing of Streaming API. Anybody could present a simple and easy-to-understand explanation ?

Gamini Sirisena
Ranch Hand

Joined: Aug 05, 2008
Posts: 347
Let me have a go...

As far I know the packages only deal with pull parsing and not push parsing.
The org.xml.sax packages are based on the push parsing model.

For me Pull parsing and Push Parsing represents two different ways of writing XML parsing code.

The push model requires a handler with required event handling methods (e.g in SAX startElement, endElement, characters etc. as defined in org.xml.sax.ContentHandler interface) implemented and the Handler Implementation needs to keep track of where in XML document the parser is in. In the push model the parser has control over the parsing and the parser calls the implemented handler methods. Writing a Hanlder for complex parsing is cumbersome with having to shuffle between a number of methods and keeping track of the current point in the XML document.

In the pull model you could write the whole parsing code within one method and the client application has control over the parsing. i.e. the programmer can decide when to look for the next event rather than the parser pushing events to a Handler Implemenation. Pull parsing code eliminates the disjoint coding nature of the push model. However it may be required to write a number of nested loops to accomplish parsing a XML Document. I like coding with the pull model.

Hope this helps....
jQuery in Action, 2nd edition
subject: Push parsing and Pull parsing of Streaming API.
Similar Threads
How to solve refresh problem in JSP
Parse XML File Using Java
Stax-DOM-SAX comparison
To author
Stax Vs SAX Parsers