[Date Prev]
| [Thread Prev]
| [Thread Next]
| [Date Next]
--
[Date Index]
| [Thread Index]
Re: Is DOM more efficient than SAX for smaller xml instances?
- From: "Mukul Gandhi" <gandhi.mukul@gmail.com>
- To: "bryan rasmussen" <rasmussen.bryan@gmail.com>
- Date: Thu, 24 Aug 2006 19:58:06 +0530
DOM and SAX are meant for *different requirements*.
If you just want the parser to push events to the application, and do
something with the XML stream, you must use SAX.
Whereas, if you want to hold the XML into memory in a tree like
fashion, and manipulate the tree in some way (like adding, deleting,
modifying nodes, and later serializing the modified tree), then you
must use DOM.
This is a rough guideline when you must use SAX model, and when you
should use DOM model.
So I must say, you must choose DOM or SAX depending on the
requirement. I can imagine that, there may be problems when DOM and
SAX both can fit into the solution. In that case you might choose SAX
for performance reasons.
There is a newer API, StAX, which gives almost the same performance as
SAX, but is a pull based model (while SAX is push based model).
On 8/24/06, bryan rasmussen <rasmussen.bryan@gmail.com> wrote:
> I seem to remember once, long ago, reading something showing DOM was
> more efficient than SAX for small XML instances - small being approx
> 40 kb.
>
> I suppose it would be more efficient for small and hierarchical but
> have hard time seeing how it would be for small and flat.
>
> At any rate: is it?
>
> Of course I know that people often find it (DOM) easier to use, but
> that has nothing to do with efficiency of the API itself.
>
>
> Cheers,
> Bryan
--
Regards,
Mukul Gandhi
http://gandhimukul.tripod.com
[Date Prev]
| [Thread Prev]
| [Thread Next]
| [Date Next]
--
[Date Index]
| [Thread Index]