SAX Parser
SAX Parser
Learn XML - XML tutorial - SAX Parser - XML examples - XML programs
SAX Parser - Event Based Parser
- Event-based parsers send parsing events directly to application logic (begin and end of element but not its attributes).
- If application logic interested in element it requests additional data from parser.
- Effective when application needs only sequential access to certain kinds of elements.
Learn XML - XML tutorial - Event Based Parser - XML examples - XML programs
Why SAX ?
- For applications that are not so XML-centric, an object-based interface is less appealing.
- Efficiency : lower level than object-based interfaces
- Event-based interface consumes fewer resources than an object-based one
- With an event-based interface, the application can start processing the document as the parser is reading it
Read Also
Android SAX ParserParsing XML : SAX
- SAX is an interface to the XML parser based on streaming and call-backs.
- We need to implement the HandlerBase interface :
- StartDocument, endDocument
- StartElement, endElement
- Characters
- Warning, error, fatalError
Learn XML - XML tutorial - Parsing XML using Sax - XML examples - XML programs
Limitations of SAX
- With SAX, it is not possible to navigate through the document as you can with a DOM.
- The application must explicitly buffer those events is interested in it.