帮你写了个,把分全给我吧
using System.Xml;
XmlDocument xmlDoc = new XmlDocument();
xmlDoc.Load(@"c:\test.xml");
XmlElement newElement = xmlDoc.CreateElement("Department");
newElement.SetAttribute("name", "CS");
for (int i = 0; i < xmlDoc.DocumentElement.ChildNodes.Count; i++)
newElement.AppendChild(xmlDoc.DocumentElement.ChildNodes[i--]);
xmlDoc.DocumentElement.AppendChild(newElement);
xmlDoc.Save(@"c:\result.xml");
using System.Xml;
XmlDocument xmlDoc = new XmlDocument();
xmlDoc.Load(@"c:\test.xml");
XmlElement newElement = xmlDoc.CreateElement("Department");
newElement.SetAttribute("name", "CS");
for (int i = 0; i < xmlDoc.DocumentElement.ChildNodes.Count; i++)
newElement.AppendChild(xmlDoc.DocumentElement.ChildNodes[i--]);
xmlDoc.DocumentElement.AppendChild(newElement);
xmlDoc.Save(@"c:\result.xml");
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货