stax xml parser java

The StAX stands for the “Streaming API for XML” which is used for reading and writing XML documents. It works similarly to SAX parser except the below differences.

Difference between StAX and SAX XML parser.

1. StAX is a pull API where SAX is a push API.
2. StAX can read and write XML documents where SAX can only read XML documents.

StAX is pull API:

StAX is a pull style API because it application have to move the StAX parser from element to element in the XML file i.e. application pulling the events from the parser.

StAX API categories:

1. Event Iterator API
2. Cursor API

Event Iterator API:

It acts as an iterator. Following are the Event Iterator API classes for reading and writing XML documents:
1. XMLEventReader: It is used for reading the XML documents.
2. XMLEventWriter: It is used for writing the XML documents.

Cursor API:

It acts as ResultSet. Following are the Cursor API classes for reading and writing XML documents:
1. XMLStreamReader: It is used for reading the XML documents.
2. XMLStreamWriter: It is used for writing the XML documents.

Stax xml parser examples:

 
Next Topic: Java StAX XMLEventReader example.
Previous Topic: SAX XML parser in java with example.

Related Topics:

How to build java project using ant in eclipse?
JAXB marshalling – convert java object to xml example.
How to create pdf file in java using iText jar?
Generics class example.
OGNL in struts 2.
Hibernate One-to-One Mapping using xml.
Send inline image in email using JavaMail API.
Quartz 2 JobListener example.