Regrading this code:
var tmpNewNode = xdoc.ImportNode(newNode, true); if (oldNode.ParentNode != null) { oldNode.ParentNode.ReplaceChild(tmpNe
Try:
oldNode.InnerXml = tmpNewNode.InnerXml