The Document Object Model (DOM) is a language-independent API for XML and HTML documents. The API represents XML and HTML documents as objects that can be accessed by object-oriented programs (such as Web browsers, document search engines, conversion tools, business logic, and scripting languages). By using the DOM, these programs can create, navigate, manipulate, and modify the documents.
See article 4.1.1.2 to learn about the supported DOM specification.
The DOM can be used to represent an existing XML document or generate an XML document. The document is stored in computer memory. However, it is not persistent.
In the DOM, a document consists of a collection of Nodes that have parent/child relationships. The Node is the primary object and can be of different types (such as, Document, Element, Attribute, Text, Processing Instruction, CDATA Section, and Comment).
The logical structure of each document has a single Document node, which has no parent and zero or more children that are Element nodes. The following figure shows the DOM for the sample XML state document:
The Document node (state) is the root of the tree. Each of the Element nodes is a tag in the state document. The tag attributes are Attribute nodes. The text (data) within each tag is a Text node.