JAXP StAX: Difference between revisions

From NovaOrdis Knowledge Base
Jump to navigation Jump to search
Line 24: Line 24:


=Cursor-Based API=
=Cursor-Based API=
The StAX cursor API represents a cursor with which one can walk an XML document from beginning to end. The cursor can point to one thing at a time, and always moves forward, usually one element at a time.
The main cursor interfaces are <tt>XMLStreamReader</tt> and <tt>XMLStreamWriter</tt>.


<blockquote style="background-color: #f9f9f9; border: solid thin lightgrey;">
<blockquote style="background-color: #f9f9f9; border: solid thin lightgrey;">

Revision as of 01:52, 11 November 2016

External

Internal

Overview

The StAX (Streaming) API provide streaming, event-driven, pull parsing for reading and writing XML documents, as an alternative to SAX push parsing and JAXP DOM full in-memory tree structure representation. StAX has an iterator-based API, where the programmer asks for the next element (pulls the event), and also a cursor-based API. In both cases, XML documents are treated as filtered series of events.

StAX parsers can be used for state-dependent processing, unlike SAX parses, which can only be used for state-independent processing.

StAX is a read/write API, XML documents can be read and written with StAX.

StAX offers a simpler programming model than SAX and more efficient memory management than JAXP DOM.

Difference between Pull Parsing and Push Parsing

Difference between Pull Parsing and Push Parsing

Cursor-Based API

The StAX cursor API represents a cursor with which one can walk an XML document from beginning to end. The cursor can point to one thing at a time, and always moves forward, usually one element at a time.

The main cursor interfaces are XMLStreamReader and XMLStreamWriter.

Cursor-based Parsing Example

Iterator-Based API

Iterator-based Parsing Example

StAX Example

StAX Example

Component Packages