Document Object Model
Document Object Model (DOM ) is a specification of an interface for accessing an HTML or XML documents. It is defined by the World Wide Web Consortium.
An implementation that meets this specification, is in the sense of object-oriented programming of a set of classes and methods, along with their attributes. It allows computer programs to dynamically change the contents of the structure and layout of a document.
- 4.1 DOM Level 0
- 4.2 DOM Level 1
- 4.3 DOM Level 2
- 4.4 DOM Level 3
Designation
The name " Document Object Model " is actually a misnomer, since DOM is defined not as a model, but as an interface ( Interface) for data access and is also referred to as the W3C. The text of label emphasizes, however, the basis of the interface well-defined object model whose validity is a prerequisite for the validity of the constructed thereon interface. At a higher level of abstraction is a model of an interface, namely the way to access objects or data.
History
DOM was originally created under the influence of at least two developments that significantly shaped the computer world in the recent past. Two is motivated by the need for the structured data in HTML and XML documents easily and be able to access uniformly.
The mid- 1990s, when once the World Wide Web grew in popularity, the JavaScript scripting language was invented and standard web browser contained since interpreter to run such scripts. JavaScript defined rudimentary ways to access the HTML document and event handling. Later, different browser makers invented different models for dynamic HTML (DHTML ), which enabled a more comprehensive change in the structure and appearance of the document while the document is displayed in the browser. However, these differences did the work for web developers who wanted to use dynamic HTML to an extremely arduous task since they were often practically forced for each to write supportive browsers own version. The first DOM W3C standards are therefore attempts that various proprietary JavaScript and DHTML techniques that emerged during the browser wars, bring together, standardize and ultimately replace. This has been achieved, so that DOM these days plays a central role in the JavaScript programming.
At the same XML emerged as a common exchange format for human-readable representation of structured data, which built on the success of HTML. For processing XML documents a comprehensive, powerful and programming language independent interface was needed. DOM offers such and also defines additional interfaces for a comfortable dealing with XML documents.
Basics of DOM is an example
The following HTML code defines a table with the table element and various sub-elements:
first name < / th> | Name < / th> tr> thead > |
---|---|
Donald < / td > | Duck < / td >
tr>
tbody >
< / table>
How it looks in a browser:
The DOM represents the table element and its subelements in the following tree structure: This example can be the basic structure of the object model to discuss: Documents are logically represented as a tree. Nodes ( nodes ) are about " relationships " with each other in connection. Types of relationshipsThe present structure is characterized by the following relations in the object model:
Starting from an arbitrary node at any other node is reachable via relationships. Types of nodesThe most important types of nodes in the DOM are:
Attribute nodes are a special type of node, because they do not come as a node in the tree in front, which is formed mainly by the element nodes. Attribute nodes thus are not " children " of element nodes, but properties of them. Processing a documentIn the first step an existing document is read by the program and creates a document object. Based on this object may be accessed content, structure, and representation means of the methods of the API. In particular DOM allows
At the end of the processing can be generated from the document object by so-called serialization a new XML or HTML document. Standardization of DOMDOM is a W3C standard since 1998, and has since been updated and expanded several times. There are several versions (levels ), each with different modules: DOM Level 0This level was never formally specified. Level 0 refers to the usable techniques using JavaScript to access HTML documents. These were introduced by web browsers like Internet Explorer and Netscape Navigator prior to the standardization of the DOM. DOM Level 1
DOM Level 2
DOM Level 3
|
|