XML DOM extractContents() method

Definition and usage

The extractContents() method deletes the document content and returns it in the form of DocumentFragment objectin the form of returning it.

Syntax:

extractContents()

Return value

A DocumentFragment node, containing the content of the range.

Throw

If the document content to be extracted is read-only, this method will throw a NO_MODIFICATION_ALLOWED_ERR code DOMException exception.

If the current range includes DocumentType node, this method will throw a HIERARCHY_REQUEST_ERR code DOMException exception.

Description

This method will delete the specified range of the document and return a DocumentFragment that contains the deleted content (or a copy of the deleted content). DocumentFragment node. When this method is returned, the range will collapse, and adjacent Text nodes may appear in the document ( Node.normalize() Can be merged).