猿问

C# XML 修改节点属性值的问题

C# XML 修改节点属性值的问题


明月笑刀无情
浏览 2812回答 5
5回答

慕田峪4524236

XmlDocument doc = new XmlDocument();doc.Load(Path.GetFullPath(file));找到这个节点 node,把node转换成XmlElement e=(XmlElement)node;e.SetAttribute("Path", ofd的全路劲);最关键的是要保存当前修改 doc.Save(Path.GetFullPath(file));

慕神8447489

XmlDocument xmlDoc = getXml("test.xml");XmlNodeList nodes = xmlDoc.SelectNodes("m//pro");foreach (XmlNode node in nodes){node.Attributes["pic"].Value = "aaa";node.Attributes["url"].Value = "bbb";}xmlDoc.Save("test.xml");
随时随地看视频慕课网APP
我要回答