Lecture 7 & 8 DOM & SAX Flashcards
1
Q
What are the advantages and disadvantages of DOM & SAX? (PART 1)
A
DOM
- •Unless you build a DOM style tree from your application’s internal representation for the data, you can’t as easily write the XML file back to disk.
VS
SAX
- •If you use DOM to construct the tree, extract the data and throw away the tree, then SAX might have been more efficient.
- •If you convert the data in the DOM tree to another format, the SAX API may help remove the intermediate step.
- •If you do not need all the XML data in memory, the SAX API allows you to process the data as it is parsed.
2
Q
What are the advantages and disadvantages of DOM & SAX? (PART 2)
A
- DOM has a Tree of Nodes Vs SAX that works with a Sequence of events
- DOM occupies more memory so its preffered for small XML documents Vs SAX which doesn’t use any memory, preffered for large documents
- DOM has a slower runtime Vs SAX with faster run time
- DOM is stored as objects Vs SAX objects are to be created
- DOM is programmtically easy, since it has objects already Vs SAX where you need to write code for creating Objects
- DOM is easy to navigate with a tree Vs SAX where backwards navigation is not possible as it sequentially processes the document