The XML DOM is used to access and manipulate the XML document programmatically. The DOM is an in-memory, cached tree representation of an XML document that enables the navigation and modification of a document including adding, updating, or deleting the content of elements. The DOM represents data as a hierarchy of object nodes.
Consider a sample XML document:
<book>
<name> Harry Potter </name>
<language> English </language>
</book>
According to the XML DOM, this document contains the following objects:
-
Document object. This includes the entire document.
-
The book object. This is a root node that has two child elements, name and language.
-
The name object. This is a text object and has a sibling object, language.
-
Gone with the Wind. This is a text object and a child of the name object.
-
The language object. This is an object that has a sibling object name and a child text object.
-
English. This is a child of the language object.
XML DOM Objects
| Object |
Description |
| DOMDocument |
Represents the top node of the XML DOM tree |
| XMLDOMNode |
Represents a single node in the DOM tree |
| XMLDOMAttribute |
Represents an attribute object |
| XMLDOMCDATASection |
Marks the text such that the text is not interpreted as markup language |
| XMLDOMDocumentType |
Contains information associated with the document declaration |
| XMLDOMEntity |
Represents an entity in the XML document |
| XMLDOMProcessingInstruction |
Represents a processing instruction |
|