用javascript訪問XML中的CDATA區(qū)內(nèi)容:
<script>
var xmlDoc = new ActiveXObject("Msxml2.DOMDocument");
var root;
var CDATASection;
xmlDoc.async = false;
xmlDoc.loadXML("<a/>");
root = xmlDoc.documentElement;
CDATASection = xmlDoc.createCDATASection("Hello World!");
root.appendChild(CDATASection);
b=xmlDoc.createElement("Test")
b.text="hahahahaha"
root.appendChild(b);
alert(root.xml);
for(i =0;i<root.childNodes.length;i++)
{
if(root.childNodes[i].nodeType==4)
alert(root.childNodes[i].nodeValue)
}
</script>
本站僅提供存儲服務(wù),所有內(nèi)容均由用戶發(fā)布,如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請
點(diǎn)擊舉報。