Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/427.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文档时getAttribute出错_Javascript_Xml_Internet Explorer - Fatal编程技术网

Javascript 在Internet Explorer中解析xml文档时getAttribute出错

Javascript 在Internet Explorer中解析xml文档时getAttribute出错,javascript,xml,internet-explorer,Javascript,Xml,Internet Explorer,我从javascript调用一个Web服务,然后解析xml并呈现表。在firefox中一切都很好,但在IE中则不同 问题似乎就在这条线上 var count = result.childNodes[0].getAttribute('Count'); 有没有一种IE友好的方法可以在javascript中获取xml属性 代码的其余部分工作正常。但不幸的是,我需要这个计数 这适用于IE 7: x=xmlDoc.getElementsByTagName("book")[0].attributes;

我从javascript调用一个Web服务,然后解析xml并呈现表。在firefox中一切都很好,但在IE中则不同

问题似乎就在这条线上

var count = result.childNodes[0].getAttribute('Count'); 
有没有一种IE友好的方法可以在javascript中获取xml属性

代码的其余部分工作正常。但不幸的是,我需要这个计数

这适用于IE 7:

x=xmlDoc.getElementsByTagName("book")[0].attributes;
document.write(x.getNamedItem("category").nodeValue);
book是元素名称,category是属性名称。我在W3学校发现了这个例子:

  • 教程:
  • 例如:
  • XML:
    • 这在IE 7中起作用:

      x=xmlDoc.getElementsByTagName("book")[0].attributes;
      document.write(x.getNamedItem("category").nodeValue);
      
      book是元素名称,category是属性名称。我在W3学校发现了这个例子:

      • 教程:
      • 例如:
      • XML:

      您知道IE有多个版本吗?告诉我们您指的是哪一个。getAttribute适用于IE中的XML文档(HTML文档存在问题)。发布的代码片段中没有错误;我们需要看更多的代码。你知道IE有不止一个版本吗?告诉我们您指的是哪一个。getAttribute适用于IE中的XML文档(HTML文档存在问题)。发布的代码片段中没有错误;我们需要看到更多的代码。