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));

One Comment

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.