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

One Reply to “Replace XElement with xml in string (C#)”

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.

Related Posts