You can perform the opposite operation—converting a DOM tree into XML or HTML
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
outerHTML properties. These properties can also be
read to fetch HTML fragments corresponding to the corresponding DOM subtree.
Note: Be aware that block-level elements
<p> will be automatically closed if another
block-level element is nested inside and therefore parsed before the closing
Creates a new
The documentation for
DOMParser.parseFromString(), this interface's only method, contains examples for parsing XML, SVG, and HTML strings.
|HTML Standard |
BCD tables only load in the browser