Baseline Widely available
The DOMParser
interface provides the ability to parse XML or HTML source code from a string into a DOM Document
.
You can perform the opposite operationâconverting a DOM tree into XML or HTML sourceâusing the XMLSerializer
interface.
In the case of an HTML document, you can also replace portions of the DOM with new DOM trees built from HTML by setting the value of the Element.innerHTML
and outerHTML
properties. These properties can also be read to fetch HTML fragments corresponding to the corresponding DOM subtree.
Note that XMLHttpRequest
can parse XML and HTML directly from a URL-addressable resource, returning a Document
in its response
property.
Note: Be aware that block-level elements like <p>
will be automatically closed if another block-level element is nested inside and therefore parsed before the closing </p>
tag.
DOMParser()
Creates a new DOMParser
object.
DOMParser.parseFromString()
Parses a string using either the HTML parser or the XML parser, returning an HTMLDocument
or XMLDocument
.
The documentation for DOMParser.parseFromString()
, this interface's only method, contains examples for parsing XML, SVG, and HTML strings.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4