Please note, new blog at http://www.acheron.org/darryl/

XML Parsers: DOM vs. SAX

I've been tinkering with Java lately, and I've been starting to playwith XML parsing. I'll have a post up soon on comparing DOM parsing with ColdFusion (I don't suspect too many!). I found this good article on devx, about the top-level differences between DOM and SAX specifications.
The W3C DOM specification provides a very rich and intuitive structure for housing the XML data, but can be quite resource-intensive given that the entire XML document is typically stored in memory. You can manipulate the DOM at run-time and stream the updated data as XML, or transform it to your own format if you require. The strength of the SAX specification is that it can scan and parse gigabytes worth of XML documents without hitting resource limits, because it does not try to create the DOM representation in memory. Instead, it raises events that you can handle as you see fit. Because of this design, the SAX implementation is generally faster and requires fewer resources. On the other hand, SAX code is frequently complex, and the lack of a document representation leaves you with the challenge of manipulating, serializing, and traversing the XML document. http://www.devx.com/xml/Article/16922/0/page/2

By Blogger anon_anon, at 11/23/2009 11:24:00 am  

you might also want to look at vtd-xml, the latest and most advanced XML processing API available today

http://vtd-xml.sf.net



» Post a Comment