XML Stream
XML stream parsing (SAX/StAX) processes XML element by element in an event-driven way without building a full DOM tree, supporting large XML files.
Purpose
To handle elements through event callbacks in memory-constrained or large-document scenarios without loading the whole document.
Mechanism
SAX: the parser fires startElement/endElement/characters events and handlers respond in callbacks. StAX: a pull model where the application calls next() on demand. No tree is built, so memory stays constant.
Use cases
- Parsing large XML files
- SAX event handling
- Streaming SOAP messages