Process and traverse DOM element attributes and methods of XML documents

Source: Internet
Author: User

Used to process DOM element attributes of XML documents
Copy codeThe Code is as follows:
ChildNodes: returns an array of all child elements of the current element;
FirstChild: returns the first sub-element of the current element;
LastChild: returns the last child element of the current element;
NextSibling: returns the elements that follow the current element;
NoedValue: Specifies the read/write attribute that represents the element value;
ParentNode: returns the parent node of the element;
Previussibling: returns the element adjacent to the current element;

DOM element method used to traverse XML documents
Copy codeThe Code is as follows:
GetElementById (id) (document): obtains the elements in the document with the specified unique ID attribute value;
GetElementsByTagName (name): returns the array of the child elements specified by the calibration name in the current element;
HasChildNodes (): returns a Boolean value indicating whether the element has child elements;
GetAttribute (name): returns the attribute value of an element, which is specified by name;

W3C DOM attributes and methods used for dynamic content creation
Copy codeThe Code is as follows:
Document. createElement (tagName): The createElement method on the document object can create elements specified by tagName. If the string div is used as the method parameter, a div element is generated;
Document. createTextNode (text): The createTextNode method of the document Object creates a node that contains static text;
<Element>. appendChild (childNode): The appendChild method adds the specified node to the subnode list of the current element (as a new subnode ). For example, you can add an option element as a subnode of the select element;
<Element>. getattrure (name): These methods obtain and set the value of the name attribute in the element respectively;
<Element>. setattrube (name, value): These methods obtain and set the value of the name attribute in the element respectively;
<Element>. insertBefore (newNode, targetNode): This method inserts the node newNode as the child node of the current element before the targetNode element;
<Element>. removeAttribute (name): This method deletes the attribute name from the element;
<Element>. removeChild (childNode): This method deletes the child element childNode from the element;
<Element>. replaceChild (newNode, oldNode): This method replaces the node oldNode with the node newNode;
<Element>. hasChildnodes (): This method returns a Boolean value that specifies whether the element has child elements;

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.