XML DOM - DOMParser object

Parse XML markup to create a document.

Constructor

new DOMParser()

Description

The DOMParser object parses XML text and returns a XML Document objectTo use DOMParser, instantiate it with the constructor without parameters, and then call its parseFromString() method:

var doc = (new DOMParser()).parseFromString("}}text)

IE does not support the DOMParser object. Instead, it supports using Document.loadXML() XML parsing of XMLHttpRequest.

Note that the XMLHttpRequest object can also parse XML documents. See the responseXML property.

DOMParser.parseFromString()

Parse XML markup

Syntax

parseFromString(text, contentType)

text is the XML markup to be parsed.

contentType is the content type of the text. It can be one of "text/xml", "application/xml", or "application/xhtml+xml". Note that "text/html" is not supported.

Return value

Save text Represents a Document object. See also Document.loadXML(), to understand a specific IE alternative to this method.