C#编辑xml文件

string path = @"C:\Users\Administrator\Desktop\无人智能便利店\install\收银端\XMLRFI.xml";
XmlDocument xmlDoc = new XmlDocument();//新建XML文件
xmlDoc.Load(path);//加载XML文件
XmlNode xm = xmlDoc.SelectSingleNode("RFI");
XmlElement xelKey = xmlDoc.CreateElement("RFIID");
XmlAttribute xelType = xmlDoc.CreateAttribute("Type");
xelType.InnerText = "data";
xelKey.SetAttributeNode(xelType);
XmlElement xelAuthor = xmlDoc.CreateElement("author");
xelKey.InnerText = "dfdsa";
xm.AppendChild(xelKey);
xmlDoc.Save(path);

猜你喜欢

转载自www.cnblogs.com/WordHorizon/p/11491567.html