DOMParser: parseFromString() method - Web APIs | MDN (original) (raw)

Baseline

Widely available

The parseFromString() method of the DOMParser interface parses a string containing either HTML or XML, returning an HTMLDocument or an XMLDocument.

Syntax

parseFromString(string, mimeType)

Parameters

string

The string to be parsed. It must contain either anHTML, xml, XHTML, orsvg document.

mimeType

A string. This string determines whether the XML parser or the HTML parser is used to parse the string. Valid values are:

A value of text/html will invoke the HTML parser, and the method will return an HTMLDocument. Any