如何用javascript访问XML中的CDATA区内容呢??

谢谢了。
---------------------------------------------------------------

 1<script>   
 2var xmlDoc = new ActiveXObject("Msxml2.DOMDocument");   
 3var root;   
 4var CDATASection;   
 5xmlDoc.async = false;   
 6xmlDoc.loadXML("<a/>");   
 7root = xmlDoc.documentElement;   
 8CDATASection = xmlDoc.createCDATASection("Hello World!");   
 9root.appendChild(CDATASection);   
10b=xmlDoc.createElement("Test")   
11b.text="hahahahaha"   
12root.appendChild(b);   
13alert(root.xml);   
14for(i =0;i<root.childNodes.length;i++)   
15{   
16if(root.childNodes[i].nodeType==4)   
17alert(root.childNodes[i].nodeValue)   
18}   
19</script>
Published At
Categories with Web编程
comments powered by Disqus