It need not be an either/or decision. SAX is a great way to deserialize data into a native format, and DOM (with a little help) is an easy, general way to generate a serializable node hierarchy, so I tend to use SAX for deserialization and DOM for serialization. You could argue that there's an extra step required in converting the native format to a DOM hierarchy, but I find it worthwhile to be able to use our DOM-based, generalized serialization classes (derived from DOMPrint) to generate correct XML.
 
-----Original Message-----
From: Vinay Kakade [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, January 02, 2002 2:56 AM
To: [EMAIL PROTECTED]
Subject: Whether to use SAX or DOM?

Hi All,
 
I am facing a design decision problem regarding whether to use Xerces C++ SAX or
DOM parser. The requirements are as follows:
 
I want to prepare a generalized (nested) linked list (so that it may contain other linked lists)
from the data in a configuration file in XML format. Then
the user will do various operations on the linked list such as add, modify,
delete nodes and can also save the modified data in the linked list back to
the configuration file.
 
I want to know whether I should use SAX or DOM parser in parsing the configuration
file.
**If I use DOM parser, I need to update the DOM tree for each operation on the
linked list such that the linked list and the DOM tree are in sync. For saving data
to configuration file, I need to traverse the DOM tree and write it to output file.
**If I use SAX parser, for saving data to confoguration file, I need to traverse the
linked list and generate XML from it.
 
Please let me know which parser should I use from the ease of implementation and
efficiency point of view.
 
Thanks in advance,
-Vinay Kakade

Reply via email to