Object XmlDocumentType
The XmlDocumentType object is used to access the entities defined by XML
Inheritance
Member attributes
name
String, returns the name of the DTD
1readonly String XmlDocumentType.name;
publicId
String, can return the public identifier of the external DTD
1readonly String XmlDocumentType.publicId;
systemId
String, can return the system identifier of the external DTD
1readonly String XmlDocumentType.systemId;
nodeType
Integer, returns the node type of the node
1readonly Integer XmlDocumentType.nodeType;
The nodeType of different objects will return different values:
- XmlElement: ELEMENT_NODE(1)
- XmlAttr: ATTRIBUTE_NODE(2)
- XmlText: TEXT_NODE(3)
- XmlCDATASection: CDATA_SECTION_NODE(4)
- XmlProcessingInstruction: PROCESSING_INSTRUCTION_NODE(7)
- XmlComment: COMMENT_NODE(8)
- XmlDocument: DOCUMENT_NODE(9)
- XmlDocumentType: DOCUMENT_TYPE_NODE(10)
nodeName
String, returns the name of the node, according to its type
1readonly String XmlDocumentType.nodeName;
The nodeName of different objects will return different values:
- XmlElement: element name
- XmlAttr: Property name
- XmlText: #text
- XmlCDATASection: #cdata-section
- XmlProcessingInstruction: Return to the specified target
- XmlComment: #comment
- XmlDocument: #document
- XmlDocumentType: doctype name
nodeValue
String, returns the name of the node, according to its type
1String XmlDocumentType.nodeValue;
The nodeName of different objects will return different values:
- XmlElement: null
- XmlAttr: The value of the attribute
- XmlText: The content of the node
- XmlCDATASection: The content of the node
- XmlProcessingInstruction: Return the specified content data
- XmlComment: Comment text
- XmlDocument: null
- XmlDocumentType: null
ownerDocument
XmlDocument, Returns the root element of the node (XmlDocument Object)
1readonly XmlDocument XmlDocumentType.ownerDocument;
parentNode
XmlNode, Can return the parent node of a node
1readonly XmlNode XmlDocumentType.parentNode;
childNodes
XmlNodeList, Returns the node list of the child nodes of the specified node
1readonly XmlNodeList XmlDocumentType.childNodes;
firstChild
XmlNode, Return the first child node of the node
1readonly XmlNode XmlDocumentType.firstChild;
lastChild
XmlNode, Return the last child node of the node
1readonly XmlNode XmlDocumentType.lastChild;
previousSibling
XmlNode, Returns the node immediately before a certain node (at the same tree level), if there is no such node, then the attribute returns null
1readonly XmlNode XmlDocumentType.previousSibling;
nextSibling
XmlNode, Returns the node immediately following an element (in the same tree level), if there is no such node, the property returns null
1readonly XmlNode XmlDocumentType.nextSibling;
Member function
hasChildNodes
Query whether there are child nodes
1Boolean XmlDocumentType.hasChildNodes();
Return result:
- Boolean, Return true if there are any child nodes, otherwise return false
normalize
Merge adjacent Text nodes and delete empty Text nodes
1XmlDocumentType.normalize();
This method will traverse all descendant nodes of the current node, and normalize the document by deleting the empty Text node and merging all adjacent Text nodes. This method is useful for simplifying the structure of the document tree after inserting or deleting nodes.
cloneNode
Create an exact copy of the specified node
1XmlNode XmlDocumentType.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 result:
- XmlNode, Return the copied node
This method will copy and return a copy of the node that called it. If the parameter passed to it is true, it will also recursively copy all descendants 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 the Element node is copied, all its attributes will be copied.
lookupPrefix
Returns the prefix matching the specified namespace URI on the current node
1String XmlDocumentType.lookupPrefix(String namespaceURI);
Call parameters:
- namespaceURI: String, specify the matching namespace URI
Return result:
- String, Returns the matched prefix, returns null if it is not matched
lookupNamespaceURI
Returns the namespace URI that matches the specified prefix on the current node
1String XmlDocumentType.lookupNamespaceURI(String prefix);
Call parameters:
- prefix: String, specify the matching prefix
Return result:
- String, Returns the matching namespace URI, returns null if it is not matched
insertBefore
Insert a new child node before the existing child node
1
2XmlNode XmlDocumentType.insertBefore(XmlNode newChild,
XmlNode refChild);
Call parameters:
Return result:
- XmlNode, Return the new child node
If newChild already exists in the document tree, it will be deleted from the document tree and then reinserted in its new position. Nodes from one document (or nodes created by one document) cannot be inserted into another document. In other words, the ownerDocument property of newChild must be the same as the ownerDocument property of the current node.
insertAfter
Insert a new child node after the existing child node
1
2XmlNode XmlDocumentType.insertAfter(XmlNode newChild,
XmlNode refChild);
Call parameters:
Return result:
- XmlNode, Return the new child node
If newChild already exists in the document tree, it will be deleted from the document tree and then reinserted in its new position. Nodes from one document (or nodes created by one document) cannot be inserted into another document. In other words, the ownerDocument property of newChild must be the same as the ownerDocument property of the current node.
appendChild
Add a new child node to the end of the node's child node list
1XmlNode XmlDocumentType.appendChild(XmlNode newChild);
Call parameters:
- newChild: XmlNode, Specify the added node
Return result:
- XmlNode, Return this new child node
If newChild already exists in the document tree, it will be deleted from the document tree and then reinserted in its new position. Nodes from one document (or nodes created by one document) cannot be inserted into another document. In other words, the ownerDocument property of newChild must be the same as the ownerDocument property of the current node.
replaceChild
Replace one child node with another
1
2XmlNode XmlDocumentType.replaceChild(XmlNode newChild,
XmlNode oldChild);
Call parameters:
Return result:
- 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 deleted from the document tree and then reinserted in its new position. Nodes from one document (or nodes created by one document) cannot be inserted into another document. In other words, the ownerDocument property of newChild must be the same as the ownerDocument property of the current node.
removeChild
Remove a node from the list of child nodes
1XmlNode XmlDocumentType.removeChild(XmlNode oldChild);
Call parameters:
- oldChild: XmlNode, Specify the node to be deleted
Return result:
- 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 returns "[Native Object]", the object can be re-implemented according to its own characteristics
1String XmlDocumentType.toString();
Return result:
- String, Returns the string representation of the object
toJSON
Returns the JSON format representation of the object, generally returns a collection of readable attributes defined by the object
1Value XmlDocumentType.toJSON(String key = "");
Call parameters:
- key: String, unused
Return result:
- Value, Returns a value containing JSON serializable