XML.orgXML.org
FOCUS AREAS |XML-DEV |XML.org DAILY NEWSLINK |REGISTRY |RESOURCES |ABOUT
OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.

 


Help: OASIS Mailing Lists Help | MarkMail Help

[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index]
Re: Is DOM more efficient than SAX for smaller xml instances?

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]


News | XML in Industry | Calendar | XML Registry
Marketplace | Resources | MyXML.org | Sponsors | Privacy Statement

Copyright 1993-2007 XML.org. This site is hosted by OASIS