XML DOM CDATASection Object

CDATASection object represents the CDATA section in the document.

instance

In the following example, we will use the XML filebooks.xml, as well as the JavaScript function loadXMLDoc().

createCDATASection() - Creates a CDATA section node

CDATASection object

The CDATASection object represents the CDATA section in the document.

The CDATASection interface is Text interface's subinterface, it does not define any of its own attributes or methods. Through Node interface inherits nodeValue attribute, or by accessing CharacterData interface inherits the data attribute, allowing access to the text content of the CDATA section.

Although CDATASection nodes can usually be treated as Text node processing, but note thatNode.normalize() method does not merge with adjacent CDATA sections.

Use Document.createCDATASection() Create a CDATASection.

CDATA sections contain text that is not parsed by the parser. Tags within CDATA sections are not considered as markup, and entities are not expanded. The main purpose is to include materials such as XML fragments without escaping all delimiters.

The only delimiter recognized within a CDATA is "]]>", which indicates the end of the CDATA section. CDATA sections cannot be nested.

Attributes of CDATASection object

Attribute Description IE F O W3C
data Set or return the text of this node. 6 1 No Yes
length Return the length of the CDATA section. 6 1 No Yes

Methods of CDATASection object

Method Description IE F O W3C
appendData() Append data to the node. 6 1 No Yes
deleteData() Delete data from the node. 6 1 No Yes
insertData() Insert data into the node. 6 1 No Yes
replaceData() Replace data in the node. 6 1 No Yes
splitText() Split CDATA into two nodes. 6 1 No  
substringData() Extract data from the node. 6 1 No Yes