【问题标题】:Javascript: View XML that was retrieved from an external sourceJavascript:查看从外部源检索的 XML
【发布时间】:2011-05-19 16:42:28
【问题描述】:

好的,这段代码:

    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 文件?

谢谢! 回复

【问题讨论】:

  • http_request.responseText 包含什么?
  • 完美!正是我想要的!您能否将以上内容写在答案中,以便我选择您的答案作为正确答案?

标签: javascript xml ajax json


【解决方案1】:

检查 http_request.responseText。只要 reponseXML 不为 null,它就应该是 Document 对象,并且可以与之交互。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2012-04-15
    • 1970-01-01
    • 2020-08-17
    • 2012-06-19
    • 1970-01-01
    • 2016-12-15
    • 2015-08-14
    • 2023-04-01
    相关资源
    最近更新 更多