Latest web development tutorials

XML DOM createCDATASection () method

Document Object Reference Document Object

Definition and Usage

createCDATASection () method creates a CDATA section node.

The method returns CDATASection object.

grammar

createCDATASection(data)

参数 描述
data 字符串,这个字符串为节点规定数据。


Examples

The following code fragment uses loadXMLDoc () to " the Books.xml " into xmlDoc, and the CDATA section node is added to the <book> element:

Examples

xmlDoc=loadXMLDoc("books.xml");

x=xmlDoc.getElementsByTagName('book');
var newCDATA,newtext;

newtext="Special Offer & Book Sale";

for (i=0;i<x.length;i++)
{
newCDATA=xmlDoc.createCDATASection(newtext);
x[i].appendChild(newCDATA);
}

try it"

Document Object Reference Document Object