DOM vs SAX parser in Java
DOM and SAX parser are two most popular parser used in Java programming language to parse XML documents.
DOM and SAX concept are originally XML concept and Java programming language just provide an API to implement these parser. Despite both DOM and SAX are used in XML parsing, they are completely different to each other. In fact
difference between DOM and SAX parser is a popular Java interview question asked during Java and XML interviews. DOM and SAX parser has different way of working, which makes Java programmer to understand difference between DOM and SAX parser even more important. Careless use of DOM parser may result in
java.lang.OutOfMemoryError if you try to parse a huge XML file and with small heap size while careless use of SAX parser may result in poor performance while parsing small and medium sized XML files with good enough
heap space in Java. In this Java article we will
compare DOM and SAX parser and learn difference between them.