两段demo代码如下(forieonly):
<scripttype="text/javascript">
//demo1
varxmlDoc=newActiveXObject("Msxml2.DOMDocument");
varroot;
varCDATASection;
xmlDoc.async=false;
xmlDoc.loadXML("<a/>");
root=xmlDoc.documentElement;
CDATASection=xmlDoc.createCDATASection("HelloWorld!");
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>
<scripttype="text/javascript">
//demo2
varxmlDoc=newActiveXObject("Msxml2.DOMDocument");
xmlDoc.async=false;
xmlDoc.loadXML("<a><![CDATA[aaaaaaaaaaaaaaaaaaaaa]]></a>");
root=xmlDoc.documentElement;
for(i=0;i<root.childNodes.length;i++)
{
if(root.childNodes[i].nodeType==4)
alert(root.childNodes[i].nodeValue)
}
</script>
//demo3(forfirefox)
<!DOCTYPEHTMLPUBLIC"-//W3C//DTDHTML4.0Transitional//EN">
<HTML>
<HEAD>
<TITLE>使firefox对xml的处理兼容IE的selectSingleNodeselectNodes方法</TITLE>
<METANAME="Author"CONTENT="emu">
<METANAME="Keywords"CONTENT="firefoxIEselectSingleNodeselectNodes">
<METANAME="Description"CONTENT="使firefox可以支持selectSingleNodeselectNodes方法">
<SCRIPTLANGUAGE="JavaScript">
<>
</SCRIPT>
</HEAD>
<BODY>
</BODY>
</HTML>
//demo4(crossbrower)
http://kb.mozillazine.org/XPath