給xml|web.config 增加節點和屬性值
string basePathConfig = this.Request.PhysicalApplicationPath.ToString()+"Web.config";
XmlDocument xmlDoc = new XmlDocument();
xmlDoc.Load(basePathConfig); //加載你的XML文件
XmlNode appSettings = xmlDoc.SelectSingleNode("/configuration/appSettings");//查找appSettings
XmlElement adds=xmlDoc.CreateElement("add");//創建add節點
adds.SetAttribute("key","test");
adds.SetAttribute("value","testvalue");
appSettings.AppendChild(adds); //追加節點
xmlDoc.Save(basePathConfig);//保存文件
Response.Write("success");成功提示
posted on 2010-03-28 16:50
sanmao 閱讀(180)
評論(0) 編輯 收藏