简体   繁体   中英

What is the typeof for a XML object in JavaScript?

I know JSON and plain text but I don't know the exact typeof for XML since I couldn't find a test link. I'm presuming it's an object since HTML DOM access uses it but I just need to make sure.

Without a code snippet to go on, you might be getting back an "XMLDocument" type (depending on the script engine).

I tried this out/verified using Chrome:

$.ajax({ url: 'http://localhost/Test/Test' })
  .done(function(f) { 
     console.log(f instanceof XMLDocument ? "XMLDocument" : "object");
  });

where my simple Test/Test returned an XML string with MIME type text/xml:

    public ActionResult Test()
    {
        return Content("<test><answer accurate=\"true\">42</answer></test>", "text/xml");
    }

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