Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/463.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/xml/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 在internet explorer上解析xml文档_Javascript_Xml - Fatal编程技术网

Javascript 在internet explorer上解析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

我想解析一个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 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’”。