Regrading this code:
var tmpNewNode = xdoc.ImportNode(newNode, true);
if (oldNode.ParentNode != null)
{
oldNode.ParentNode.ReplaceChild(tmpNe
Along the lines of what MarkXA said:
What's probably happening here is that newNode comes from a document with no namespace declared, but oldNode is in a document with a namespace. In this situation, the node takes its blank namespace over to the new document and it shows up explicitly.
You could manipulate the String for the purpose of the comparison but the nodes in your DOM would not be namespace qualified correctly which could cause you problems later if you tried to use it.
The correct solution would be to build newNode with the proper namespace qualification in the first place. By propery namespace qualification, I mean the namespaces used in the importing DOM.