Widely available Supported across all major browsers. Safe to use in production.

Browser support

Feature Desktop Mobile
Chrome
Edge
Firefox
Safari
Chrome Android
Safari iOS
1
12
1
1.3
18
1

The DOMParser() constructor creates a new DOMParser object. This object can be used to parse the text of a document using the parseFromString() method.

1
12
1
1.3
18
1

The parseFromString() method of the DOMParser interface parses an input containing either HTML or XML, returning a Document with the type given in the Document/contentType property.

1
12
1
1.3
18
1
parseFromString (html)

HTML (`text/html`) support

31
12
12
9.1
31
9.3
parseFromString (xml)

XML (`application/xml`) support

1
12
1
1.3
18
1
1+Supported (version) Not supported Has note Sub-feature descriptions sourced from MDN Web Docs (CC BY-SA 2.5)

Use cases

  • Using DOMParser

    The DOMParser interface provides the ability to parse XML or HTML source code from a string into a DOM Document.

Cautions

  • May not be supported in older browsers.

Implementation notes

  • Some APIs require a secure context (HTTPS) or user activation. Check the requirements before use.