給xml|web.config 增加節(jié)點(diǎn)和屬性值
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");//創(chuàng)建add節(jié)點(diǎn)
adds.SetAttribute("key","test");
adds.SetAttribute("value","testvalue");
appSettings.AppendChild(adds); //追加節(jié)點(diǎn)
xmlDoc.Save(basePathConfig);//保存文件
Response.Write("success");成功提示
posted on 2010-03-28 16:50
sanmao 閱讀(181)
評(píng)論(0) 編輯 收藏