创建属性Attribute

XmlDocument xmlDoc = new XmlDocument();
xmlDoc.Load(xmlPath);
var root = xmlDoc.DocumentElement;//取到根结点
XmlElement node = (XmlElement)xmlDoc.SelectSingleNode("BookStore/NewBook");
node.SetAttribute("Name", "WPF");
xmlDoc.Save(xmlPath);

posted @ 2017-10-23 11:07  任飞儿  阅读(216)  评论(0编辑  收藏  举报