Nov 10, 2018

What is difference between DOM and SAX parser ?

Main difference between DOM and SAX parser is the way they parse XML documents. DOM creates an in memory tree representation of XML documents during parsing while SAX is a event driven parser.

Both DOM and SAX parser are extensively used to read and parse XML file in java and have there own set of advantage and disadvantage. Though there is another way of reading xml file using xpath in Java which is more selective approach like SQL statements people tend to stick with XML parsers. DOM Parser vs SAX parsers are also often viewed in terms of speed, memory consumption and there ability to process large XML files.