XML DOM importNode() Method

Document Object Reference Manual

Definition and Usage

The importNode() method copies a node from another document to the current document for application.

Syntax:

importNode(importedNode,deep)
Parameter Description
importedNode The node to be imported.
deep If true, all descendant nodes of the importedNode node must also be recursively copied.

Return Value

importedNode a copy of (and possibly its descendant nodes), its ownerDocument property is set to the document.

throws

if importedNode is a Document node or DocumentType node, and the NOT_SUPPORTED_ERR code will be thrown DOMException Exceptionbecause these types of nodes cannot be imported.

Description

The parameter of this method is a node defined in another document, and the return value is a copy of the node suitable for insertion into the document. If deep If the value is true, then all descendant nodes of the node must also be copied. In any case, the original node and its descendant nodes will not be modified.

The ownerDocument property of the returned copy is set to the current document, but the parentNode property is null because it has not been inserted into the document yet. Event listener functions registered on the original node or tree are not copied.

Only attributes explicitly set in the source document are imported when importing Element nodes. When importing Attr nodes, its specified attribute is automatically set to true.

See

Node.cloneNode()

Document Object Reference Manual