public static void appendChild(Node parent,Node child){
  Document ownerDoc=getOwnerDocument(parent);
  if (child.getOwnerDocument() != ownerDoc) {
    parent.appendChild(ownerDoc.importNode(child,true));
  }
 else {
    parent.appendChild(child);
  }
}

public static void appendChild ( Node parent , Node child ) { Document ownerDoc = getOwnerDocument ( parent ) ; if ( child . getOwnerDocument ( ) != ownerDoc ) { parent . appendChild ( ownerDoc . importNode ( child , true ) ) ; } else { parent . appendChild ( child ) ; } }
checks if child element has same owner document before appending to the parent , and imports it to the parent ' s document if necessary .
