两段demo代码如下(for ie only): <script> <BR>//demo1 <BR>var xmlDoc = new ActiveXObject("Msxml2.DOMDocument"); <BR>var root; <BR>var CDATASection; <BR>xmlDoc.async = false; <BR>xmlDoc.loadXML("<a/>"); <BR>root = xmlDoc.documentElement; <BR>CDATASection = xmlDoc.createCDATASection("Hello World!"); <BR>root.appendChild(CDATASection); <BR>b=xmlDoc.createElement("Test") <BR>b.text="hahahahaha" <BR>root.appendChild(b); <BR>alert(root.xml); <BR>for(i =0;i<root.childNodes.length;i++) <BR>{ <BR>if(root.childNodes[i].nodeType==4) <BR>alert(root.childNodes[i].nodeValue) <BR>} <BR></script>
<script> <BR>//demo2 <BR>var xmlDoc = new ActiveXObject("Msxml2.DOMDocument"); <BR>xmlDoc.async = false; <BR>xmlDoc.loadXML("<a><![CDATA[aaaaaaaaaaaaaaaaaaaaa]]>"); <BR>root = xmlDoc.documentElement; <BR>for(i =0;i<root.childNodes.length;i++) <BR>{ <BR>if(root.childNodes[i].nodeType==4) <BR>alert(root.childNodes[i].nodeValue) <BR>} <BR></script>
//demo3( for firefox) 使firefox对xml的处理兼容IE的selectSingleNode selectNodes方法 TITLE >
SCRIPT >
HEAD >
BODY >
HTML >
//demo4( cross brower)
http://kb.mozillazine.org/XPath