adoptNode: adoptNode, source(3)
Similar to importNode( )
,
this method is used to migrate a DOM Node
from one Document
instance to another. The source
node is removed from the DOM tree of its parent document and
prepared to be inserted into the adopting document, unlike the
importNode()
method which
creates a copy of the source node and leaves the original in
place. The following table explains the behavior of this method
for the individual node types:
Node type | Result |
---|---|
| Adopts the source attribute and all its
children. The |
| Adopts the |
| Cannot be adopted. |
| Cannot be adopted. |
| Adopts the element as well as all child
nodes. Adopts the attribute nodes that have their |
| Cannot be adopted. |
| Adopts only the |
| Cannot be adopted. |
| All adopted without restrictions. |
Since the newly adopted node was not created by the target
document, it is possible that the names of elements, attributes,
etc., may not conform to the XML version of the new document (see
the xmlVersion
attribute).
Consider using the normalizeDocument(
)
method to ensure that adopted nodes are
well-formed.