Try to use code like this to modify the value in xml:
public static void Main (string[] args)
{
XDocument xdoc = XDocument.Load(@"file.xml");
var element = xdoc.Root.Elements("MyXmlElement").Single();
element.Value = "new value";
xdoc.Save(@"file.xml");
}
It seems that there is no particularly good way to determine whether certain attributes exist except for adding some if statements.
If the response is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.