Blog on software engineering
Replace XElement with xml in string (C#)

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

One comment

Leave a Reply

Your email address will not be published.

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