Regrading this code:
var tmpNewNode = xdoc.ImportNode(newNode, true);
if (oldNode.ParentNode != null)
{
oldNode.ParentNode.ReplaceChild(tmpNewNode, oldNode);
return true;
}
tmpNewNode is created with empty xmlns attribute (xmlns=""). Any suggestion how can I avoid it?
10x
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With