The DOM approach loads the entire document into a defined in-memory structure that you can later randomly access and manipulate using defined functions. For files like settings or XML representations of an editable document this is often a good choice.
The SAX approach asks you program to react to a parts of a stream of XML as it arrives, either by reading from a file or across a network etc., and do something there and then. For constructing your own in-memory data structures or performing some immediate action in response to the XML in a single pass SAX is a good choice.
Efficiency generally says that you do not rewrite something that works, i.e. your DOM solution, unless there is a good reason. What are you trying to achieve?




Reply With Quote
Bookmarks