创建一个 CDATA section 节点

  1. <html>
  2. <head>
  3. <script type="text/javascript" src="/example/xdom/loadxmldoc.js"></script>
  4. </head>
  5. <body>
  6.  
  7. <script type="text/javascript">
  8. xmlDoc=loadXMLDoc("/example/xdom/books.xml");
  9.  
  10. newCDATA=xmlDoc.createCDATASection("Special Offer & Book Sale");
  11.  
  12. x=xmlDoc.getElementsByTagName("book")[0];
  13. x.appendChild(newCDATA);
  14.  
  15. document.write(x.lastChild.nodeValue);
  16. </script>
  17. </body>
  18. </html>