| 
好友1
 在线时间0 小时
 最后登录2025-4-29
 
 见习骑士 
 
 UID3209025
 第纳尔1316 
 精华0
 互助2 
 荣誉0 
 贡献0 
 魅力20 
 注册时间2020-11-30
    
   鲜花(3 )   鸡蛋(0 ) | 
 
 
 楼主|
发表于 2022-3-13 01:36:32
|
显示全部楼层 
| using System; using System.IO;
 using System.Xml;
 
 namespace XmlEditor
 {
 class Program
 {
 static void AddSkillById(XmlDocument doc,string id,int add)
 {
 string xpath = String.Format("//skill[@id='{0}']", id);
 XmlNodeList list = doc.SelectNodes(xpath);
 foreach (XmlNode node in list)
 {
 XmlElement ele = (XmlElement)node;
 String val = ele.GetAttribute("value");
 int i = Convert.ToInt32(val);
 i += add;
 ele.SetAttribute("value", i.ToString());
 }
 }
 static void Main(string[] args)
 {
 string path = Directory.GetCurrentDirectory() + @"\\spnpccharacters.xml";
 XmlDocument doc = new XmlDocument();
 doc.Load(path);
 
 AddSkillById(doc, "OneHanded", 200);
 AddSkillById(doc, "TwoHanded", 200);
 AddSkillById(doc, "Polearm", 200);
 
 string path2 = Directory.GetCurrentDirectory() + @"\\spnpccharacters_new.xml";
 doc.Save(path2);
 }
 }
 }
 
 | 
 |