给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");成功提示

相关文章:

  • 2021-06-22
  • 2022-12-23
  • 2022-12-23
  • 2021-05-16
  • 2021-09-10
  • 2021-05-27
猜你喜欢
  • 2022-12-23
  • 2022-03-01
  • 2022-12-23
  • 2021-07-17
  • 2021-07-13
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案