The Document Object Model (DOM) is a W3C standard. It defines a standard for accessing documents like HTML and XML.
Definition of DOM as put by the W3C
The Document Object Model (DOM) is an application programming interface (API) for HTML and XML documents. It defines the logical structure of documents and the way a document is accessed and manipulated.
DOM defines the objects and properties and methods (interface) to access all XML elements. The DOM is separated into 3 different parts / levels:
Core DOM – standard model for any structured document
XML DOM – standard model for XML documents
HTML DOM – standard model for HTML documents
XML DOM is a standard object model for XML. XML documents have a hierarchy of informational units called nodes; DOM is a standard programming interface of describing those nodes and the relationships between them.
As XML DOM also provides an API that allows a developer to add, edit, move or remove nodes at any point on the tree in order to create an application.
Below is the diagram for the DOM structure which depicts that parser evaluates an XML document as a DOM structure by traversing through each nodes.
XML DOM is language and platform independent.
XML DOM is travesible – Information in XML DOM is organized in a hierarchy which allows developer to navigate around the hierarchy looking for specific information.
XML DOM is modifiable – It is dynamic in nature providing developer a scope to add, edit, move or remove nodes at any point on the tree.
It consumes more memory (if the XML structure is large) as program written once remains in memory all the time until and unless removed explicitly.
Due to the larger usage of memory its operational speed, compared to SAX is slower.