开发者

XElement 'Add' Not doing it right? [closed]

开发者 https://www.devze.com 2023-03-13 18:48 出处:网络
This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time,or an extraordinarily narrow situation that is not generally applic
This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center. Closed 10 years ago.

Using:

XElement kd = XElement.Load(path);
kd.Add(new XElement("players",开发者_运维技巧
       new XAttribute("name", username),
       new XElement("kills", 0),
       new XElement("deaths", 0)));

Nothing is added to XML file:

<?xml version="1.0" encoding="utf-8"?>
<SimpleKD>
  <player name="Tardis">
    <kills>0</kills>
    <deaths>0</deaths>
    </player>
</SimpleKD>

Am I doing it wrong?


You do not appear to be saving the file. Try

kd.Save(path);
0

精彩评论

暂无评论...
验证码 换一张
取 消