Javascript 在internet explorer上解析xml文档
我想解析一个xml文档。 以下是一段代码片段:Javascript 在internet explorer上解析xml文档,javascript,xml,Javascript,Xml,我想解析一个xml文档。 以下是一段代码片段: //Following is on receiving the xml doc self.xmlHttpReq.onreadystatechange = function() { if(self.xmlHttpReq.readyState == 4 && self.xmlHttpReq.status == 200) { if (navigator.appName == 'Microsoft Internet
//Following is on receiving the xml doc
self.xmlHttpReq.onreadystatechange = function()
{
if(self.xmlHttpReq.readyState == 4 && self.xmlHttpReq.status == 200)
{
if (navigator.appName == 'Microsoft Internet Explorer')
{
xmlDoc = self.xmlHttpReq.responseText;
var reqst = new RegExp("<d0>0"); //This could only get binary value
//How to parse in IE??
}
else // Moz, Chrome
{
xmlDoc = self.xmlHttpReq.responseXML;
xmldat1 = xmlDoc.getElementsByTagName('d0')[0].firstChild.nodeValue;
xmldat2 = xmlDoc.getElementsByTagName('d1')[0].firstChild.nodeValue;
}
}
//以下是在接收xml文档时
self.xmlHttpReq.onreadystatechange=函数()
{
if(self.xmlHttpReq.readyState==4&&self.xmlHttpReq.status==200)
{
如果(navigator.appName==“Microsoft Internet Explorer”)
{
xmlDoc=self.xmlHttpReq.responseText;
var reqst=new RegExp(“0”);//这只能获取二进制值
//如何在IE中解析??
}
else//Moz,Chrome
{
xmlDoc=self.xmlHttpReq.responseXML;
xmldat1=xmlDoc.getElementsByTagName('d0')[0].firstChild.nodeValue;
xmldat2=xmlDoc.getElementsByTagName('d1')[0].firstChild.nodeValue;
}
}
上面的解析对于mozilla和chrome很有效,但是对于IE,我如何进行解析?注意:我不能使用任何jquery技术。在解析IE5和IE6时,需要设置这一行:
xmlhttp=newActivexObject(“Microsoft.xmlhttp”);
检查此链接:
这可能有助于您更好地理解。我希望您用于Mozilla和Chrome的代码在IE tooNo中运行良好,IE抛出“对象不支持属性或方法‘getElementsByTagName’”。