What Is the Document Object Model?
The Document Object Model (DOM for short) is a standard programming interface for extensible markup languages recommended by the W3C organization. It is a platform and language independent application program interface (API), which can dynamically access programs and scripts, update their content, structure, and style of www documents (currently, HTML and XML documents are defined through the description section) . The document can be further processed, and the processed result can be added to the current page. DOM is a tree-based API document that requires the entire document to be represented in memory during processing. Another simple API is event-based SAX, which can be used to process very large XML documents. Because of its large size, it is not suitable for processing all in memory.
- Document Object Model (DOM)
- Document Object Model DOM
- DOM is the document object model. It is a standard interface specification formulated by the W3C. It is a standard API for processing HTML and XML files. The DOM provides an access model to the entire document, and treats the document as a tree structure. Each node of the tree represents an HTML tag or a text item within the tag. The DOM tree structure accurately describes the interconnections between tags in HTML documents. The process of converting an HTML or XML document into a DOM tree is called parse. After the HTML document is parsed, it is transformed into a DOM tree. Therefore, the processing of the HTML document can be realized through the operation of the DOM tree. The DOM model not only describes the structure of the document, but also defines the behavior of the node object. Using the methods and properties of the object, you can easily access, modify, add and delete the nodes and content of the DOM tree.
- The main interfaces are
- The history of the Document Object Model can be traced back to the "browser wars" [3] (browser wars) of Microsoft and Netscape in the late 1990s. Both parties gave the browser and powerful functions in order to fight against each other in JavaScript and JScript. Microsoft has added a lot of exclusive things to webpage technology, including VBScript, ActiveX, and Microsoft's own DHTML format, so that many webpages cannot be displayed properly using non-Microsoft platforms and browsers. The DOM was a masterpiece of the time.
- DOM is divided into HTML DOM and XML DOM. They define standard methods for accessing and manipulating HTML / XML documents, respectively, and present the corresponding documents as a tree structure (node tree) with elements, attributes, and text, as shown in the following figure:
- 2) In the DOM tree, there is a root node, and all other nodes are descendants of the root node.
- 3) In the application process, a DOM-based HTML / XML parser converts an HTML / XML document into a DOM tree. The application program operates on the DOM tree to implement operations on the HTML / XML document data.