This article lists some DOM element attributes and methods used to process and traverse XML documents and W3CDOM attributes and methods used to dynamically create content. If you have any requirements, refer to them, we hope to help you with the DOM element attributes of XML documents.
The 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
The 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
The Code is as follows:
Document. createElement (tagName): The createElement method on the document object can create elements specified by tagName. If the string p is used as the method parameter, a p element is generated;
Document. createTextNode (text): The createTextNode method of the document Object creates a node that contains static text;
. 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;
. Getattrure (name): These methods obtain and set the value of the name attribute in the element respectively;
. Setattrube (name, value): These methods obtain and set the value of the name attribute in the element respectively;
. InsertBefore (newNode, targetNode): This method inserts the node newNode as the child node of the current element before the targetNode element;
. RemoveAttribute (name): This method deletes the attribute name from the element;
. RemoveChild (childNode): This method deletes the child element childNode from the element;
. ReplaceChild (newNode, oldNode): This method replaces the node oldNode with the node newNode;
. HasChildnodes (): This method returns a Boolean value that specifies whether the element has child elements;