This article describes the differences and links between xml dom and html dom. dom?entobjectmodel, Document Object Model) defines a set of standard methods for accessing and operating documents. First, let's take a look at the usage of xml dom.
XML DOM
Xml dom (xmlbeanentobjectmodel) defines a set of standard methods for accessing and operating XML documents.
DOM views XML documents as a tree structure. All elements can be accessed through the DOM tree. You can modify or delete their content and create new elements. Elements, their text, and their attributes are considered as nodes.
In the following example, we use DOM reference to obtain text from the <to> element:
- xmlDoc.getElementsByTagName("to")[0]
- .childNodes[0].nodeValue
◆ XmlDoc-XML document created by the parser
◆ GetElementsByTagName ("to") [0]-first <to> element
◆ ChildNodes [0]-<to> the text node of the first child element of the element)
◆ NodeValue-value Text of the node itself)
You can learn more in the xml dom tutorial of 51cto.com.
HTML DOM
Html dom (html?entobjectmodel) defines a set of standard methods for accessing and operating HTML documents.
You can use html dom to access all HTML elements.
In the following example, we use DOM reference to change the text of the HTML element id = ":
- document.getElementById("to").innerHTML=
-
◆ Document-HTML document
◆ GetElementById ("to")-the id = "to" HTML Element
◆ InnerHTML-internal text of the HTML Element
You can learn more in the html dom tutorial of 51cto.com.