The DOM and SAX APIs can each parse documents efficiently given appropriate
conditions. The following table summarizes and compares the
characteristics of the DOM API with those of the SAX API:
Table 2. Comparing the DOM API with the SAX API
| DOM
| SAX
|
Type of Interface
| Object-based
| Event-based
|
Object Model
| Created automatically
| Must be created by application
|
Element Sequencing 1
| Preserved
| Ignored in favor of single events
|
Use of TPF Memory
| Higher
| Lower
|
Speed of Initial Data Retrieval
| Slower
| Faster
|
Stored Information
| Better for complex structures
| Better for simple structures
|
Validation
| Optional
| Optional
|
Ability to Update XML Document
| Yes (in memory)
| No
|
Notes:
- Element sequencing refers to the ability of the API to
remember the order of the elements. DOM can traverse the tree structure
in memory; SAX locates a specific element and ignores the surrounding
elements.
|
For more detailed information about the two APIs, go to DOM or SAX.