XML DOM » Document » createCDATASection

Syntax:
document.createCDATASection(data)
data
The string data that will be assigned as the value of the new CDATASection object.

This method creates a CDATASection object whose value is the data supplied as the argument.

Creating an instance of this object does not automatically include it in the XML Document tree, and so its parentNode property is set to null.

Examples

Code:
Set objXMLDoc = CreateObject("Microsoft.XMLDOM")
objXMLDoc.async = False
objXMLDoc.load("quotations.xml")

Dim root, objNewCDATA, currNode
Set root = objXMLDoc.documentElement
Set objNewCDATA = objXMLDoc.createCDATASection("Copyright Notice")
root.appendChild(objNewCDATA)

Set currNode = root.lastChild
document.write(currNode.nodeType)
document.write("<br>" & currNode.nodeName)
document.write("<br>" & currNode.nodeValue)
Output:
4
#cdata-section
Copyright Notice
Explanation:

This example creates a CDATASection consisting of a copyright notice, and appends it to the children of the document's root element. It then displays the new node's type, name and value. The value '4' returned for the node's type indicates that it is a CDATASection object (see the list of node types).

Language(s): VBScript

See Also: