The Document Object Model (DOM)
The Document Object Model is a platform- and language-neutral interface that will allow programs and scripts to dynamically access and update the content, structure and style of documents. The document can be further processed and the results of that processing can be incorporated back into the presented page. The Document Object Model also contains a set of interfaces for an application that reads an XML (Extensible Markup Language) file into memory and stores it as a tree structure. The abstract API (Application Programming Interface) allows for constructing, accessing and manipulating the structure and content of XML and HTML documents.
The DOM is extremely useful for random-access applications. SAX (another API used in XML) only allows you a view of one bit of the document at a time. If you are looking at one SAX element, you have no access to another. If you are looking at a text node, you have no access to a containing element.
When you write a SAX application, you need to keep track of your program's position in the document somewhere in your own code. SAX does not do it for you. Also, if you need to look ahead in the XML document, you are just out of luck.
Some applications are simply impossible in an event driven model with no access to a tree. Of course you could build some sort of tree yourself in SAX events, but the DOM allows you to avoid writing that code. The DOM is a standard tree representation for XML data.
The Document Object Model Levels 0 & 1 are currently full W3C recommendations. The Document Object Model Level 2 is currently a Working Draft, and is subject to change. The DOM Level 2 is the section of the DOM that includes event handling,