Document.createCDATASection(data)
The createCDATASection method creates a CDATASection
object whose value is the text 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.
The following 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.
Code (VBScript):
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
The value '4' returned for the node's type indicates that it is a
CDATASection object (see the list of
node types).
|