JAXP StAX: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
|||
Line 9: | Line 9: | ||
=Overview= | =Overview= | ||
The StAX (Streaming) API provide streaming, event-driven, pull parsing for reading and writing XML documents, as an alternative to [[JAXP SAX|SAX]] push parsing and [[JAXP DOM]] full in-memory tree structure representation. StAX has an [[ | The StAX (Streaming) API provide streaming, event-driven, pull parsing for reading and writing XML documents, as an alternative to [[JAXP SAX|SAX]] push parsing and [[JAXP DOM]] full in-memory tree structure representation. StAX has an [[#Iterator-Based_API|''iterator''-based API]], where the programmer asks for the next element (pulls the event), and also a [[#Cursor-Based_API|''cursor''-based API]]. | ||
StAX parsers can be used for state-dependent processing, unlike SAX parses, which can only be used for state-independent processing. | StAX parsers can be used for state-dependent processing, unlike SAX parses, which can only be used for state-independent processing. | ||
Line 25: | Line 25: | ||
=Cursor-Based API= | =Cursor-Based API= | ||
[[StAX_Example#Cursor-Based_Parsing|Cursor-based Parsing Example]] | <blockquote style="background-color: #f9f9f9; border: solid thin lightgrey;"> | ||
:[[StAX_Example#Cursor-Based_Parsing|Cursor-based Parsing Example]] | |||
</blockquote> | |||
=Iterator-Based API= | =Iterator-Based API= | ||
[[StAX_Example#Iterator-Based_Parsing|Iterator-based Parsing Example]] | <blockquote style="background-color: #f9f9f9; border: solid thin lightgrey;"> | ||
:[[StAX_Example#Iterator-Based_Parsing|Iterator-based Parsing Example]] | |||
</blockquote> | |||
=StAX Example= | =StAX Example= |
Revision as of 01:48, 11 November 2016
External
- Elliotte Rusty Harold introduction to StAX http://www.xml.com/pub/a/2003/09/17/stax.html
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.
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
Cursor-Based API
Iterator-Based API
StAX Example
Component Packages
- javax.xml.stream defines the XMLStreamReader and XMLStreamWriter interfaces.
- javax.xml.transform.stax provide StAX specific transformation APIs.