Object built-in object

ObjectXmlNode

The XmlNode object is the basic data type of the entire DOM

inheritance relationship

%0 object object toString() toJSON() XmlNode XmlNode nodeType nodeName nodeValue ownerDocument parentNode childNodes children firstChild lastChild previousSibling nextSibling firstElementChild lastElementChild previousElementSibling nextElementSibling textContent hasChildNodes() normalize() cloneNode() lookupPrefix() lookupNamespaceURI() insertBefore() insertAfter() appendChild() replaceChild() removeChild() object->XmlNode XmlCharacterData XmlCharacterData XmlNode->XmlCharacterData XmlDocument XmlDocument XmlNode->XmlDocument XmlDocumentType XmlDocumentType XmlNode->XmlDocumentType XmlElement XmlElement XmlNode->XmlElement XmlProcessingInstruction XmlProcessingInstruction XmlNode->XmlProcessingInstruction XmlComment XmlComment XmlCharacterData->XmlComment XmlText XmlText XmlCharacterData->XmlText XmlCDATASection XmlCDATASection XmlText->XmlCDATASection

member properties

nodeType

Integer, returns the node type of the node

1
readonly Integer XmlNode.nodeType;

The nodeType of different objects will return different values:


nodeName

String, returns the name of the node, according to its type

1
readonly String XmlNode.nodeName;

The nodeName of different objects will return different values:


nodeValue

String, returns the name of the node, according to its type

1
String XmlNode.nodeValue;

The nodeName of different objects will return different values:


ownerDocument

XmlDocument, returns the root element of the node (XmlDocumentobject)

1
readonly XmlDocument XmlNode.ownerDocument;

parentNode

XmlNode, can return the parent node of a node

1
readonly XmlNode XmlNode.parentNode;

childNodes

XmlNodeList, returns the node list of the child nodes of the specified node

1
readonly XmlNodeList XmlNode.childNodes;

children

XmlNodeList, returns the node list of the child element nodes of the specified node.

1
readonly XmlNodeList XmlNode.children;

firstChild

XmlNode, returns the first child node of the node

1
readonly XmlNode XmlNode.firstChild;

lastChild

XmlNode, returns the last child node of the node

1
readonly XmlNode XmlNode.lastChild;

previousSibling

XmlNode, returns the node immediately before a node (at the same tree level). If there is no such node, then this property returns null

1
readonly XmlNode XmlNode.previousSibling;

nextSibling

XmlNode, returns the node immediately following an element (in the same tree level). If there is no such node, the attribute returns null.

1
readonly XmlNode XmlNode.nextSibling;

firstElementChild

XmlNode, returns the first child element node of the node

1
readonly XmlNode XmlNode.firstElementChild;

lastElementChild

XmlNode, returns the last child element node of the node

1
readonly XmlNode XmlNode.lastElementChild;

previousElementSibling

XmlNode, returns the element node immediately before a node (at the same tree level). If there is no such node, then this property returns null

1
readonly XmlNode XmlNode.previousElementSibling;

nextElementSibling

XmlNode, returns the element node immediately following an element (in the same tree level). If there is no such node, the attribute returns null

1
readonly XmlNode XmlNode.nextElementSibling;

textContent

String, queries and sets the text of the selected element. When querying, returns the values ​​of all text nodes within the element node; when setting, deletes all child nodes and replaces them with a single text node.

1
String XmlNode.textContent;

member function

hasChildNodes

Query whether there are child nodes

1
Boolean XmlNode.hasChildNodes();

Return results:

  • Boolean, returns true if there are any child nodes, otherwise returns false

normalize

Merge adjacent Text nodes and delete empty Text nodes

1
XmlNode.normalize();

This method will traverse all descendant nodes of the current node and normalize the document by deleting empty Text nodes and merging all adjacent Text nodes. This method is useful for simplifying the structure of the document tree after inserting or deleting nodes.


cloneNode

Creates an exact copy of the specified node

1
XmlNode XmlNode.cloneNode(Boolean deep = true);

Call parameters:

  • deep: Boolean, whether to deep copy, when true, the cloned node will clone all child nodes of the original node

Return results:

  • XmlNode, returns the copied node

This method will copy and return a copy of the node on which it was called. If the argument passed to it is true, it will also recursively copy all descendant nodes of the current node. Otherwise, it only copies the current node. The returned node does not belong to the document tree and its parentNode property is null. When an Element node is copied, all its properties will be copied.


lookupPrefix

Returns the prefix matching the specified namespace URI on the current node

1
String XmlNode.lookupPrefix(String namespaceURI);

Call parameters:

  • namespaceURI: String, specifies the matching namespace URI

Return results:

  • String, returns the matching prefix, returns null if not matched.

lookupNamespaceURI

Returns the namespace URI matching the specified prefix on the current node

1
String XmlNode.lookupNamespaceURI(String prefix);

Call parameters:

  • prefix: String, specifies the matching prefix

Return results:

  • String, returns the matching namespace URI, returns null if not matched.

insertBefore

Insert a new child node before an existing child node

1 2
XmlNode XmlNode.insertBefore(XmlNode newChild, XmlNode refChild);

Call parameters:

  • newChild: XmlNode, insert new node
  • refChild: XmlNode, insert a new node before this node

Return results:

  • XmlNode, returns the new child node

If newChild already exists in the document tree, it will be removed from the document tree and reinserted in its new position. Nodes from one document (or nodes created by one document) cannot be inserted into another document. That is, the ownerDocument attribute of newChild must be the same as the ownerDocument attribute of the current node.


insertAfter

Insert a new child node after an existing child node

1 2
XmlNode XmlNode.insertAfter(XmlNode newChild, XmlNode refChild);

Call parameters:

  • newChild: XmlNode, insert new node
  • refChild: XmlNode, insert a new node after this node

Return results:

  • XmlNode, returns the new child node

If newChild already exists in the document tree, it will be removed from the document tree and reinserted in its new position. Nodes from one document (or nodes created by one document) cannot be inserted into another document. That is, the ownerDocument attribute of newChild must be the same as the ownerDocument attribute of the current node.


appendChild

Adds a new child node to the end of a node's child node list

1
XmlNode XmlNode.appendChild(XmlNode newChild);

Call parameters:

  • newChild: XmlNode, specify the added node

Return results:

  • XmlNode, returns this new child node

If newChild already exists in the document tree, it will be removed from the document tree and reinserted in its new position. Nodes from one document (or nodes created by one document) cannot be inserted into another document. That is, the ownerDocument attribute of newChild must be the same as the ownerDocument attribute of the current node.


replaceChild

Replace a child node with another

1 2
XmlNode XmlNode.replaceChild(XmlNode newChild, XmlNode oldChild);

Call parameters:

  • newChild: XmlNode, specify the new node
  • oldChild: XmlNode, specifies the node to be replaced

Return results:

  • XmlNode, If the replacement is successful, this method can return the replaced node. If the replacement fails, it returns null.

If newChild already exists in the document tree, it will be removed from the document tree and reinserted in its new position. Nodes from one document (or nodes created by one document) cannot be inserted into another document. That is, the ownerDocument attribute of newChild must be the same as the ownerDocument attribute of the current node.


removeChild

Remove a node from the list of child nodes

1
XmlNode XmlNode.removeChild(XmlNode oldChild);

Call parameters:

  • oldChild: XmlNode, specifies the deleted node

Return results:

  • XmlNode, If the deletion is successful, this method can return the deleted node. If it fails, it returns null.

toString

Returns the string representation of the object. Generally, "[Native Object]" is returned. The object can be re-implemented according to its own characteristics.

1
String XmlNode.toString();

Return results:

  • String, returns the string representation of the object

toJSON

Returns a JSON format representation of the object, generally returning a collection of readable properties defined by the object.

1
Value XmlNode.toJSON(String key = "");

Call parameters:

  • key: String, not used

Return results:

  • Value, returns a value containing JSON serializable