Cursor API
The StAX cursor API is modeled around the concept of a cursor that’s used to walk an XML document from beginning to end. The cursor points to one thing at a time, and always moves forward one XML document component at a time.
The cursor API includes interfaces for both reading and writing XML—XMLStreamReader and XMLStreamWriter. XMLStreamReader supports accessor methods for the retrieval of not just elements and attributes but namespaces, text nodes, comments, and processing instructions—the entire XML information set. To get data at the current cursor location, the cursor API includes XMLStreamReader methods such as getText and getName.
The XMLStreamReader resembles SAX in a variety of ways. Methods are available to access the string content of elements, and integer indexes are used to access attribute and namespace information. However, the cursor API also includes XMLStreamWriter for creating XML, something that SAX doesn’t support.