1. Create a node:
Create a new element node: createelement () [Reference = Document. createelement (element )]
Create a new text node: createtextnode () [Reference = Document. createtextnode (text )]
2. Copy nodes:Clonenode () [Reference = node. clonenode (deep) // The parameter deep value of this method can only be true/false, indicating whether to copy the child nodes of the replication node to the new node together]
3. Insert nodes:
Append a subnode to a given element.
Appendchild () [Reference = element. appendchild (newchild) // newchild will be the last node of the element node]
Insert a given node to a given element node before the child node
Insertbefore () [Reference = element. insertbefore (newnode, targetnode )]
4. delete a node:Removechild () [Reference = element. removechild (node) // delete a subnode from a given element node]
5. Replace nodes:ReplaceChild () [Reference = element. replaceChild (newchild, oldchild) // replace one subnode in a given parent element with another node]
6. processing nodes:
7. Search nodes:
Getattribute () [attributevalue = element. getattribute (attributename) // returns the value of a given attribute node for a given element]
Getelementbyid () [element = Document. getelementbyid (ID) // find an element with a given ID attribute value]
Getelementsbytagname () [elements = Document. getelementsbytagname (tagname) // you can call this operation to find all the elements that have been signed for the calibration. A set is returned]
Haschildnodes [booleanvalue = element. haschildnodes // check whether a given element has subnodes. Neither the text node nor the attribute node can contain any subnodes]
8. node attributes:Each node in the document has the following attributes:
Nodename is a read-only attribute [name = node. nodename // The element name returned by the element node, the attribute node returns the attribute name, and the text node returns the string # text]
Nodetype indicates the type of the given node. [integer = node. nodetype // nodetype has 12 optional values]
Nodevalue indicates the current value of the given node [value = node. nodevalue // This attribute returns a string. The attribute node returns the value of this attribute. The text node returns the content of this text node, and the element node returns NULL]
9. traverse the node tree:
The childnodes attribute returns an array consisting of subnodes of a given element node: nodelist = node. childnodes, number of subnodes: node. childnodes. length, read-only attribute
The firstchild attribute returns the first child node of a given element node: reference = node. firstchild is equivalent to reference = node. childnodes [0], read-only attribute
The lastchild attribute returns the last child node of a given element node: reference = node. lastchild is equivalent to reference = node. childnodes [node. childnodes. Length-1], read-only.
Nextsibling attribute, returns the next node of a given node: reference = node. nextsibling, read-only attribute
Returns the parent node of a given node: reference = node. the node returned by the parentnode and parentnode attributes is always an element node, because only the element node can contain the child node except the document node.
Previussibling attribute, returns the previous subnode of a given node: reference = node. previoussibling, read-only attribute