Best Practices for DOM (Windows CE 5.0)
The following topics describe some scenarios in which it is better to use the DOM to parse documents.
When you need to perform XSLT transformations
The DOM works better for XSL Transformations (XSLT) where the source XML document is transformed based on the XSLT template applied. For example, to create multiple views of the same data, you must transform it using one of two style sheets. In order for this transformation to take place, you must also create two instances of the DOM. One stores the XML source; the other stores the transformed content.
When you need complex XPath filtering
Use the DOM if you must perform complex XML Path Language (XPath) filtering and retain complex data structures that hold context information. The tree structure of the DOM retains context information automatically. With SAX, you must retain the context information yourself.
When you want to modify and save XML
The DOM allows you to create or modify a document in memory, as well as read a document from an XML source file. SAX is designed for reading, not writing, XML documents. The DOM is the better choice for modifying an XML document and saving the changed document to memory.
When you need random access to data
If random access to information is crucial, it is better to use the DOM to create a tree structure for the data in memory.
See Also
Choosing Between SAX and DOM | Best Practices for SAX | Limitations of SAX
Send Feedback on this topic to the authors