XML DOM importNode() methode
Definitie en gebruik
importNode() methode kopieert een knoop van een andere document naar dit document om toe te passen.
语法:
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 (and possibly its descendant nodes), its ownerDocument attribute is set to this 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 attribute of the returned copy is set to the current document, but the parentNode attribute is null because it has not been inserted into the document yet. Event listener functions registered in 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.