Home > Web Front-end > JS Tutorial > Processing and traversing XML document DOM element attributes and methods arrangement_Basic knowledge

Processing and traversing XML document DOM element attributes and methods arrangement_Basic knowledge

WBOY
Release: 2016-05-16 17:24:39
Original
1256 people have browsed it

DOM element attributes for processing XML documents

Copy code The code is as follows:

childNodes: Return An array of all child elements of the current element;
firstChild: returns the first subordinate child element of the current element;
lastChild: returns the last child element of the current element;
nextSibling: returns the element immediately following the current element element;
noedValue: specifies the read/write attribute representing the element value;
parentNode: returns the parent node of the element;
previousSibling: returns the element immediately before the current element;

DOM element method for traversing XML documents
Copy code The code is as follows:

getElementById( id)(document): Get the element in the document with the specified unique ID attribute value;
getElementsByTagName(name): Return an array of child elements with the specified tag name in the current element;
hasChildNodes(): Return a Boolean value , indicating whether the element has child elements;
getAttribute(name): Returns the attribute value of the element, the attribute is specified by name;

W3C DOM attributes and methods used when dynamically creating content
Copy code The code is as follows:

document.createElement(tagName): The createElement method on the document object can create For the element specified by tagName, if the string div is used as the method parameter, a div element will be generated;
document.createTextNode(text): The createTextNode method of the document object will create a node containing static text;
< element>.appendChild(childNode): The appendChild method adds the specified node to the current element's child node list (as a new child node). For example, you can add an option element as a child node of the select element;
.getAttriture(name): These methods obtain and set the value of the name attribute in the element respectively;
.setAttritube (name, value): These methods respectively obtain and set the value of the name attribute in the element;
.insertBefore(newNode, targetNode): This method inserts the node newNode as a child node of the current element in front of the targetNode element ;
.removeAttribute(name): This method removes the attribute name from the element;
.removeChild(childNode): This method removes the child element childNode from the element;
< ;element>.replaceChild(newNode,oldNode): This method replaces the node oldNode with the node newNode;
.hasChildnodes(): This method returns a Boolean value, specifying whether the element has child elements;
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template