SAX or DOM for XML

jayze333

New Member
Hi,

I'm new at progress for calling some objects from an Webservice. I have a xml-code from a webservice and i want to know what i have to do to retrieve the data from this xml document. With SAX or with DOM...


Thanks in advance
 

TomBascom

Curmudgeon
Personally I prefer SAX. It's simple, easy and uses far less memory etc. But it is an event driven "streaming" approach and if your logic isn't compatible with that then you might need (or prefer) to use DOM instead.
 

RealHeavyDude

Well-Known Member
DOM: The whole XML document is loaded into memory and from there you acutally do a XML node walk to parse the document. This limits the size of XML documents you can or may want to load into memory - but you don't need a complex logic to know your context.

SAX: The SAX parser is event driven and you get an event for each XML element and attribute that is hit by the parser. There is almost no limit to the size of XML documents you can parse - but you need a logic to know the contect because the events themselves will only give you the name of the XML element or attribute and their values but no context informtion (for example what the parent was).

Personally, I also prefer SAX over DOM.

HTH, RealHeavyDude.
 

barriers

New Member
SAX is actually very difficult to use due to its streaming, forward only nature, if you don't load documents in memory you won't be able to do anything sophisticated...

VTD-XML is the latest and most advanced XML processing model that is far more powerful than SAX, it is memory efficient (1/5 of DOM), and supports random access and XPath

http:/java.dzone.com/articles/introduction-vtd-xml
 

RealHeavyDude

Well-Known Member
Unfortunately - to my knowledge - DOM and SAX are the only XML processing that is supported in the ABL.

So one has to choose between the lesser of two evils?

Regards, RealHeavyDude.
 

TomBascom

Curmudgeon
Personally I find SAX dead simple and far more usable specifically because of its event driven, streaming nature.
 
Top