a simpler way is to use classes in System.Xml string sFile = "your.xml";
XmlDocument doc = new XmlDocument();
//doc.LoadXml("<DBRoot/>");
doc.Load(sFile); XmlNode root = doc.DocumentElement; //Create a new node.
XmlElement elem = doc.CreateElement("DB");
XmlElement elem2 = doc.CreateElement("name");
elem2.InnerText = "abc";
XmlElement elem3 = doc.CreateElement("sid");
elem3.InnerText = "acccc"; elem.AppendChild(elem2);
elem.AppendChild(elem3);
//Add the node to the document.
root.AppendChild(elem);
doc.Save(sFile);also see
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemxmlxmlnodeclassappendchildtopic.asp
XmlDocument doc = new XmlDocument();
//doc.LoadXml("<DBRoot/>");
doc.Load(sFile); XmlNode root = doc.DocumentElement; //Create a new node.
XmlElement elem = doc.CreateElement("DB");
XmlElement elem2 = doc.CreateElement("name");
elem2.InnerText = "abc";
XmlElement elem3 = doc.CreateElement("sid");
elem3.InnerText = "acccc"; elem.AppendChild(elem2);
elem.AppendChild(elem3);
//Add the node to the document.
root.AppendChild(elem);
doc.Save(sFile);also see
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemxmlxmlnodeclassappendchildtopic.asp
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货