Search code examples
c#xmlsetvalue

C# -- XElement.SetValue("value") does nothing, returns nothing


My code more or less boils down to this:

XDocument memberDB = XDocument.Load("my-path.xml");
var rank = memberDB.Descendants... Blah blah (this part works)
foreach (var g in rank) {
  g.SetValue("thing");
}

I've already gotten the selector working, so that's not the problem, and no error message is returned. Code after the g.SetValue line is still executed, but the XML document remains unchanged. What do?


Solution

  • You need to save your document after editing.

    memberDB.Save("my-path.xml")