简体   繁体   English

JavaScript中XML对象的类型是什么?

[英]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. 我知道,JSON和纯文本,但我不知道确切typeof为XML,因为我无法找到一个测试环节。 I'm presuming it's an object since HTML DOM access uses it but I just need to make sure. 我假设它是一个object因为HTML DOM访问使用了它,但是我只需要确定一下即可。

Without a code snippet to go on, you might be getting back an "XMLDocument" type (depending on the script engine). 如果没有代码片段,您可能会找回“ XMLDocument”类型(取决于脚本引擎)。

I tried this out/verified using Chrome: 我使用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: 我的简单Test / Test返回了一个MIME类型为text / xml的XML字符串:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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