about xml importNode

must I call ImportNode before using a node with ReplaceChild, or AppendChild?

yes if the documentOwner of the new node is different from the document where you are executing the action