代码示例:(标识:xdom_createcdatasection_1)
<html>
<head>
<script type="text/javascript" src="/static/demo/html/js/loadxmldoc.js"></script>
</head>
<body>

<script type="text/javascript">
xmlDoc=loadXMLDoc("/static/demo/xdom/books.xml");

newCDATA=xmlDoc.createCDATASection("Special Offer & Book Sale");

x=xmlDoc.getElementsByTagName("book")[0];
x.appendChild(newCDATA);

document.write(x.lastChild.nodeValue);
</script>
</body>
</html>
运行结果: