SAX

There are two basic approaches to parsing an XML document:

  • The event-based approach. Under this approach, an XML parser reads an XML document one chunk at a time, processing each tag as it finds it in the document. Each time the parser encounters an XML construct (an element start tag, a CDATA block, or a PI), it generates an event that can be intercepted and processed by the application layer. A Simple API for XML (SAX) parser uses this event-based approach to parsing an XML document.

  • The tree-based approach (DOM). Here, an XML parser reads the entire document into memory at one time, and creates a hierarchical tree representation of it in memory. The parser also exposes a number of traversal methods, which developers can use to navigate ...

Get XML and PHP now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.