Regrading this code:
var tmpNewNode = xdoc.ImportNode(newNode, true);
if (oldNode.ParentNode != null)
{
oldNode.ParentNode.ReplaceChild(tmpNe
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. To be honest, if it's only a problem for a string comparison, it won't hurt to just remove all instances of xmlns="" from the XML string before you work with it.