The Document Object Model, DOM for short, is an abstract data structure that represents XML documents as trees made up of nodes. Various interfaces in the org.w3c.dom package represent elements, attributes, parsed character data, comments, and processing instructions. All of these are subinterfaces of the common Node interface, which provides basic methods for navigating and pruning the tree.
The root of the tree is a Document object that represents a complete, well- formed document. A parser reads an XML document from a stream and builds a Document object representing that XML document. The client program calls the methods of Document and the other DOM interfaces to navigate the tree and extract information from the document. Programs can also manipulate the tree in memory to add, delete, move, or change its nodes. Programs can even create completely new documents from scratch in memory, and these new documents are then written into an XML file.