Yahoo Answers is shutting down on May 4th, 2021 (Eastern Time) and beginning April 20th, 2021 (Eastern Time) the Yahoo Answers website will be in read-only mode. There will be no changes to other Yahoo properties or services, or your Yahoo account. You can find more information about the Yahoo Answers shutdown and how to download your data on this help page.

what is pull and push parsing?

I am researching XML parsing. And I want to know about pull and push parsing.

1 Answer

  • 2 decades ago
    Favorite Answer

    A push parsing model is a model where the parser pushes parsing events to the application. SAX (stands for Simple API for XML) is the most common example of a push parsing API for XML. An application using SAX would define a number of callback that would be called by the parser when certain events occur. for example, an application can define a startElement method, that the parser will call every time it sees the beginning of a new element. SAX is a one-pass parser that goes through the document once from begging to end and sends one event to the calling application for each XML construct it encounters.

    A pull parsing mode is a model in which the application drives the parser (in contrast to the push model, where the parser drives the application), by pulling parsed xml constructs from the parser one by one, according to its needs. StAX (Streamin API for XML) is the most prevalent Java pull parsing API. in the StAX model, an application calls the parser's next() method iteretively - each call returns the next XML construct in the document.

    Historically SAX existed before StAX, and StAX was introduced to fix a few shortcomings of the SAX model - mainly that using SAX event model forces the application to maintain state variables to keep up with the document context while events are received from the parser. Wi the pull model, a more natural prcessing flow can be maintained, where different parts of the XML document can be delegated to different methods.

Still have questions? Get your answers by asking now.