Revealing the relationship between xml dom and HTML DOM

Source: Internet
Author: User

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:

 
 
  1. xmlDoc.getElementsByTagName("to")[0]  
  2. .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 = ":

 
 
  1. document.getElementById("to").innerHTML=  
  2.  

◆ 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.
 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.