XMLHttpRequest: responseXML property - Web APIs | MDN

Value

A Document from parsing the XML or HTML received using XMLHttpRequest, or null if no data was received or if the data is not XML/HTML.

Exceptions

InvalidStateError DOMException

Thrown if the responseType isn't either document or an empty string.

Examples

js

const xhr = new XMLHttpRequest();
xhr.open("GET", "/server");

// If specified, responseType must be empty string or "document"
xhr.responseType = "document";

// Force the response to be parsed as XML
xhr.overrideMimeType("text/xml");

xhr.onload = () => {
  if (xhr.readyState === xhr.DONE && xhr.status === 200) {
    console.log(xhr.response, xhr.responseXML);
  }
};

xhr.send();

Specifications

Specification
XMLHttpRequest
# the-responsexml-attribute

Browser compatibility

See also

Help improve MDN

Learn how to contribute

This page was last modified on by MDN contributors.