DOM Performance Tip - adoptNode
By binu on Dec 04, 2006
DOM Level 3 introduced adoptNode which allows you to adopt a node from another document to this document. This effectively allows moving a subtree from one document to another (unlike
importNode()which create a copy of the source node instead of moving it). adoptNode is much more performance efficient than importNode especially for deep Nodes since it avoids the creation and copying overheads. My experiments using XMLTest (with UBL Invoice document) showed a performance improvement of about 25%. Note that this large performance improvement is for a microbenchmark, improvement for your application may vary.