Javascript:查看从外部源检索的 XML
好吧,这段代码:
http_request = false;
http_request = new XMLHttpRequest();
if (http_request.overrideMimeType) {
http_request.overrideMimeType('text/xml');
}
if (!http_request){return false;}
http_request.open('GET', realXmlUrl, true);
http_request.send(null);
xmlDoc = http_request.responseXML;
似乎成功获取了外部xml文件。
但是当我尝试查看它时...通过执行诸如 alert(xmlDoc);
之类的操作,它不会让我看到实际的 xml 文件;(
我如何查看实际的 XML 文件?
谢谢! 右
Ok, this piece of code:
http_request = false;
http_request = new XMLHttpRequest();
if (http_request.overrideMimeType) {
http_request.overrideMimeType('text/xml');
}
if (!http_request){return false;}
http_request.open('GET', realXmlUrl, true);
http_request.send(null);
xmlDoc = http_request.responseXML;
seems to successfully get an external xml file.
Butwhen I try to view it... by doing something like alert(xmlDoc);
it wont let me see the actual xml file ;(
how do I see the actual XML file?
Thanks!
R
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
检查http_request.responseText。只要 reponseXML 不为 null,它就应该是一个 Document 对象并且可以与之交互。
Check http_request.responseText. As long as reponseXML isn't null, it should be a Document object and can be interacted with as such.