createContextualFragment

The Range.createContextualFragment() method of the Range interface returns a DocumentFragment representing the parsed input HTML or XML.

MDN Reference