IE8 中 AJAX 调用后解析 XML 响应
我正在尝试解析从 AJAX 调用返回的 XML 文档到我编写的 PHP 脚本。在 Chrome 中,这是有效的
xmlDoc.getElementsByTagName("line")[0].attributes.getNamedItem("pdfWidth").value
:
xmlDocis an object created from
parser.parseFromString(xmlhttp.responseText,"text/xml");
在IE中,
xmlDocis created by:
xmlDoc=new ActiveXObject("Microsoft.XMLDOM");
xmlDoc.async="false";
xmlDoc.loadXML(xmlhttp.responseText);
然而,上面的“getElementsByTagName”返回未定义。不确定我在这里做错了什么,有人可以帮忙吗?
编辑 - 我想我已经怀疑了它,但我显然无法回答我自己的问题..
我想我可能已经怀疑了这个 - 以下似乎有效:
xmlDoc.getElementsByTagName("line").item(0).getAttribute("pdfWidth");
花了我一个小时,grrrr IE !
I'm trying to parse an XML document returned from an AJAX call to a PHP script I've written. In Chrome, this works:
xmlDoc.getElementsByTagName("line")[0].attributes.getNamedItem("pdfWidth").value
where
xmlDoc
is an object created from
parser.parseFromString(xmlhttp.responseText,"text/xml");
In IE,
xmlDoc
is created by:
xmlDoc=new ActiveXObject("Microsoft.XMLDOM");
xmlDoc.async="false";
xmlDoc.loadXML(xmlhttp.responseText);
However the above 'getElementsByTagName' returns undefined. Not sure what I'm doing wrong here, can anyone assist?
Edit - think I've sussed it, but I can't answer my own question apparently..
I think I may have sussed this - the following seems to worK:
xmlDoc.getElementsByTagName("line").item(0).getAttribute("pdfWidth");
Took me an hour that, grrrr IE!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我想我可能已经怀疑了这一点 - 以下似乎有效:
花了我一个小时,grrrr IE!
I think I may have sussed this - the following seems to worK:
Took me an hour that, grrrr IE!