ObjectXmlCDATASection
The XmlCDATASection object represents the CDATA section in the document
The XmlCDATASection interface isXmlTextA sub-interface of an interface does not define any of its own properties and methods. by fromXmlNodeThe interface inherits the nodeValue property, or passes it fromXmlCharacterDataThe interface inherits the data attribute and can access the text content of the CDATA Section.
Although you can usually think of the XmlCDATASection node asXmlTextNode handling, but be carefulXmlNodeThe normalize method does not merge adjacent CDATA sections.
useXmlDocumentThe createXmlCDATASection method to create an XmlCDATASection.
The CDATA section contains text that will not be parsed by the parser. Tags in CDATA sections are not treated as tags, and entities are not expanded. The main purpose is to contain material such as XML fragments without escaping all delimiters.
The only recognized delimiter in a CDATA is "]]>", which marks the end of the CDATA section. CDATA sections cannot be nested.
inheritance relationship
member properties
data
String, the text contained in this node
1String XmlCDATASection.data;
length
Integer, the number of characters contained in this node
1readonly Integer XmlCDATASection.length;
nodeType
Integer, returns the node type of the node
1readonly Integer XmlCDATASection.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 XmlCDATASection.nodeName;
The nodeName of different objects will return different values:
- XmlElement:element name
- XmlAttr: attribute name
- XmlText: #text
- XmlCDATASection: #cdata-section
- XmlProcessingInstruction: Returns the specified target target
- XmlComment: #comment
- XmlDocument: #document
- XmlDocumentType: doctype name
nodeValue
String, returns the name of the node, according to its type
1String XmlCDATASection.nodeValue;
The nodeName of different objects will return different values:
- XmlElement: null
- XmlAttr: attribute value
- XmlText: the content of the node
- XmlCDATASection: the content of the node
- XmlProcessingInstruction: Returns the specified content data
- XmlComment: annotation text
- XmlDocument: null
- XmlDocumentType: null
ownerDocument
XmlDocument, returns the root element of the node (XmlDocumentobject)
1readonly XmlDocument XmlCDATASection.ownerDocument;
parentNode
XmlNode, can return the parent node of a node
1readonly XmlNode XmlCDATASection.parentNode;
childNodes
XmlNodeList, returns the node list of the child nodes of the specified node
1readonly XmlNodeList XmlCDATASection.childNodes;
children
XmlNodeList, returns the node list of the child element nodes of the specified node.
1readonly XmlNodeList XmlCDATASection.children;
firstChild
XmlNode, returns the first child node of the node
1readonly XmlNode XmlCDATASection.firstChild;
lastChild
XmlNode, returns the last child node of the node
1readonly XmlNode XmlCDATASection.lastChild;
previousSibling
XmlNode, returns the node immediately preceding a node (at the same tree level). If there is no such node, then this property returns null.
1readonly XmlNode XmlCDATASection.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.
1readonly XmlNode XmlCDATASection.nextSibling;
firstElementChild
XmlNode, returns the first child element node of the node
1readonly XmlNode XmlCDATASection.firstElementChild;
lastElementChild
XmlNode, returns the last child element node of the node
1readonly XmlNode XmlCDATASection.lastElementChild;
previousElementSibling
XmlNode, returns the element node immediately preceding a node (at the same tree level). If there is no such node, then this property returns null.
1readonly XmlNode XmlCDATASection.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.
1readonly XmlNode XmlCDATASection.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.
1String XmlCDATASection.textContent;
member function
splitText
Split the text node into two nodes according to the specified offset
1XmlText XmlCDATASection.splitText(Integer offset);
Call parameters:
- offset: Integer, specifies where to split text nodes. The starting value starts with 0
Return results:
- XmlText, Text node split from the current node
This method will place theXmlTextThe node is split into two nodes. originalXmlTextThe node will be modified so that it contains the text content before (but not including) the text content at the position specified by offset. newXmlTextNodes will be created to store all characters from the offset position (including the character at this position) to the end of the original character. newXmlTextNode is the return value of this method. Furthermore, if the originalXmlTextNode has parentNode, newXmlTextThe node will be inserted into this parent node, immediately after the original node.
The XmlCDATASection interface inheritsXmlTextinterface, XmlCDATASection nodes can also use this method, but the newly created node is an XmlCDATASection node instead ofXmlTextnode.
substringData
Extract substring from node
1
2String XmlCDATASection.substringData(Integer offset,
Integer count);
Call parameters:
- offset: Integer, the position of the first character to be returned
- count: Integer, the number of characters in the substring to be returned
Return results:
- String, returns the extracted string
appendData
Append string to node
1XmlCDATASection.appendData(String arg);
Call parameters:
- arg: String, the string to be appended to the node
insertData
Insert string into node
1
2XmlCDATASection.insertData(Integer offset,
String arg);
Call parameters:
- offset: Integer, the character position at which the string is to be inserted into the node
- arg: String, the string to be inserted
deleteData
Remove text from node
1
2XmlCDATASection.deleteData(Integer offset,
Integer count);
Call parameters:
- offset: Integer, the position of the first character to be deleted
- count: Integer, the number of characters to delete
replaceData
Replace the characters of the node with the specified string
1
2
3XmlCDATASection.replaceData(Integer offset,
Integer count,
String arg);
Call parameters:
- offset: Integer, the character position of the node to be replaced
- count: Integer, the number of characters to replace
- arg: String, the string to be inserted
hasChildNodes
Query whether there are child nodes
1Boolean XmlCDATASection.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
1XmlCDATASection.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
1XmlNode XmlCDATASection.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
1String XmlCDATASection.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
1String XmlCDATASection.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
2XmlNode XmlCDATASection.insertBefore(XmlNode newChild,
XmlNode refChild);
Call parameters:
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
2XmlNode XmlCDATASection.insertAfter(XmlNode newChild,
XmlNode refChild);
Call parameters:
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
1XmlNode XmlCDATASection.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
2XmlNode XmlCDATASection.replaceChild(XmlNode newChild,
XmlNode oldChild);
Call parameters:
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
1XmlNode XmlCDATASection.removeChild(XmlNode oldChild);
Call parameters:
- oldChild:XmlNode, specifies the node to be deleted
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.
1String XmlCDATASection.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.
1Value XmlCDATASection.toJSON(String key = "");
Call parameters:
- key: String, not used
Return results:
- Value, returns a value containing JSON serializable