简体   繁体   中英

Javascript: View XML that was retrieved from an external source

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

Check http_request.responseText. As long as reponseXML isn't null, it should be a Document object and can be interacted with as such.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM