public void Update(Setting setting) { var doc = GetDoc(); var ele = doc.Root.Element("settings").Elements().Where(x => x.Attribute(XName.Get("key")).Value == setting.Key).First(); ele.Value = setting.Value; doc.Save(xmlfile); }
public void Insert(Setting setting) { var doc = GetDoc(); XElement ele = new XElement("setting"); ele.Add(new XAttribute("key", setting.Key)); ele.Value = setting.Value; doc.Root.Element(XName.Get("settings")).Add(ele); doc.Save(xmlfile); }