Name

importNode: importedNode, deep(2)

Synopsis

This method’s name is somewhat deceptive. It creates a copy of a Node object from another document that can be inserted within the current document’s node hierarchy. Specifics of this copy operation vary, depending on the type of copied node, as described in this table:

Node type

Result

Effect of deep flag

ATTRIBUTE_NODE

Adopts the source attribute and all its children. The ownerElement attribute is set to null, and the specified flag is set to true.

None.

DOCUMENT_FRAGMENT_NODE

Creates an empty DocumentFragment node.

Fully copies the children of the source DocumentFragment node.

DOCUMENT_NODE

Cannot be imported.

N/A.

DOCUMENT_TYPE_NODE

Cannot be imported.

N/A.

ELEMENT_NODE

Adopts the attribute nodes with the specified flag set to the new element.

Recursively copies all the source element’s children.

ENTITY_NODE

Adopts the publicId, systemId, and notationName attributes.

Recursively copies all of the Entity node’s children.

ENTITY_REFERENCE_NODE

Adopts only the EntityReference node. Its value, if any, is taken from the DTD of the document doing the import.

None.

NOTATION_NODE

Imports the notation node, but since the DocumentType interface is read-only in Level 2, it cannot be included in the target document.

None.

PROCESSING_INSTRUCTION_NODE

Adopts the target and data values.

None.

TEXT_NODE, CDATA_SECTION_NODE, COMMENT_NODE

Adopts the data and length attributes.

None.

The new (copied) node object is returned based on the arguments.

Arguments

importedNode: ...

Get XML in a Nutshell, 3rd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.