Main Page

Previous Section Next Section

When to Use SAX

In general, SAX processing is faster than DOM, because it does not keep track of or build in memory trees of the document, thus consuming less memory, and does not look ahead in the document to resolve node references. Since access is sequential, it is well suited to applications interested in reading XML data and applications that do not need to manipulate the data, such as applications that read data for rendering and applications that read configuration data defined in XML. However if the primary motivation is to read the data so as to subsequently process it as Java objects, JAXB is a better choice. This is covered in Chapter 13.

Applications that need to filter XML data by adding, removing, or modifying specific elements in the data are also well suited for SAX access. The XML can be read serially and the specific element modified.

Previous Section Next Section

JavaScript Editor Java Tutorials Free JavaScript Editor