XHR纯XML响应类型

XHR pure XML responseType

本文关键字:类型 响应 XML XHR      更新时间:2023-09-26

可以将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,'');

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