C#编辑xml文件
程序员文章站
2022-04-14 23:27:51
string path = @"C:\Users\Administrator\Desktop\无人智能便利店\install\收银端\XMLRFI.xml"; XmlDocument xmlDoc = new XmlDocument();//新建XML文件 xmlDoc.Load(path);//加 ......
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);