Document Object Model (DOM) is a platform and language independent interface description for accessing the elements of an HTML or XML document. DOM was defined by the Word Wide Web Consortium (W3C) and presented in three so-called levels, each of which consists of several modules. The levels Legacy DOM, W3C DOM and IE 4 DOM are differentiated, which are supported by the different browsers in different ways.
With the help of DOM it is possible to map a document to an object model, so that further processing can then take place on the basis of the logical structure - independent of square brackets and character references.
A similarly abstract interface to Document Object Model (DOM) is Simple API for XML (SAX), which can also be used to access XML documents. A combination of the two technologies is also quite possible - with SAX, for example, a document can first be prepared so that it can then be processed further with the DOM model.
Uniform interfaces for web documentsThe starting point for the development of DOM by the W3C was the intention to realize uniform interfaces - also called Application Programming Interface (API) - for accessing Web documents such as the Extensible Markup Language (XML) or the Hypertext Markup Language (HTML). The reason for this were the individual efforts of some browser manufacturers, which got out of hand in the past and led to incompatibilities. To date, there are three versions of DOM, referred to by the W3C as levels, each containing several modules:
Level 1 Defines the core of DOM and supports XML 1.0 and HTML 4.0.
Level 2. among other things standardization of the event interface, extension by XML namespaces, possibilities for the dynamic update of CSS stylesheets.
The result of these levels is finally a number of interfaces defined using the Interface Definition Language (IDL) developed by the Object Management Group (OMG), whose advantage is to be completely language independent. With a view to easy integration into a specific environment, additional language mappings for Java and ECMAScript, for example, have been provided by the OMG. So-called bindings also regulate for other languages how the DOM interfaces are integrated and implemented in a specific development environment.
The various manufacturers of browsers such as Netscape Navigator, MozillaFirefox or Opera support the DOM in various forms or supplement the DOM, such as Internet Explorer, with elements for modifying the content of documents.
Interfaces as information unitsThe interfaces of the DOM represent the information units of an HTML or XML document as a hierarchical tree of objects, also called nodes. The tree is made available in memory so as to realize fast, direct retrieval and manipulation of these nodes. For this set of objects ordered by DOM, an abstract superclass with a certain number of attributes and methods is provided in each case. DOM provides, starting from a special node object, several other objects, such as
- Document: represents the entire document,
- NodeList: represents a list of nodes,
- Element: represents an element node,
- Attr: represents an attribute node and
- Tex:, represents a text node.
Classic applications for the DOM to handle XML and HTML documents are:
- Reading a document for read and write operations or searching for specific content,
- structuring and sorting,
- Creation of DOM trees by an application and transformation into an XML document,
- separation of references between individual XML elements,
- creation of modified DOM trees,
- Event-handling software components can be connected to the event mechanisms of the DOM trees.