本文共 1513 字,大约阅读时间需要 5 分钟。
public static void UpdateSetValue(string tagName, string value) { XmlDocument xmlDoc = new XmlDocument(); xmlDoc.Load("config.xml"); //加载xml文件 // XmlNode node = xmlDoc.GetElementById("Config"); XmlNodeList nodes = xmlDoc.SelectSingleNode("Config").ChildNodes; for (int i = 0; i < nodes.Count; i++) { MessageBox.Show(nodes[i].Name); if (nodes[i].Name.Equals(tagName)) { nodes[i].InnerText = value; } } try { //保存上面的修改 xmlDoc.Save("config.xml"); } catch (Exception e) { throw e; } } public static string GetNodeValue(string tagName) { string result = ""; XmlDocument xmlDoc = new XmlDocument(); xmlDoc.Load("config.xml"); //加载xml文件 // XmlNode node = xmlDoc.GetElementById("Config"); XmlNodeList nodes = xmlDoc.SelectSingleNode("Config").ChildNodes; for (int i = 0; i < nodes.Count; i++) { if (nodes[i].Name.Equals(tagName)) { result = nodes[i].innerText; return result ; } } return result; }
Eva 56.5 True True
转载地址:http://lhumf.baihongyu.com/