Replace XElement with xml in string (C#)
If you want to replace an existing XElement by an new XElement conctructed from a string, you can use the XElement ReplaceWith method: XElement element = new XElement("MyName", "MyContent"); string newValue = "<MyNewName>Some value</MyNewName>"; element.ReplaceWith(XElement.Parse(newValue));