XHR纯XML responseType

时间:2015-12-28 15:20:39

标签: javascript xml xmlhttprequest

可以将XHR配置为使用

接收HTML文档
xhr.responseType = "document";

收到响应后,xhr.responseXML会保存HTML文档,并根据HTML命名空间URI进行解析。你可以查看:

xhr.responseXML.children[0].namespaceURI === 'http://www.w3.org/1999/xhtml'

如何获得纯XML文档响应,而不是解析为HTML,如:

document.implementation.createDocument(null,'');

1 个答案:

答案 0 :(得分:1)

没有找到有关此问题的文档,但似乎(至少FF和Chromium)js引擎根据资源的文件扩展名解析xhr.responseXML
它转换为HTML .html文件和通用XML .xml文件