zoukankan      html  css  js  c++  java
  • asp.net操作XML

    代码
    using System;
    using System.Xml;

    public partial class Web_Admin_Admin_Basic : System.Web.UI.Page
    {
    protected void Page_Load(object sender, EventArgs e)
    {
    if (!IsPostBack)
    {
    string sFile = Server.MapPath("../Web.config");
    XmlDocument xmldoc
    = new XmlDocument();
    xmldoc.Load(sFile);

    XmlNodeList topm
    = xmldoc.DocumentElement.ChildNodes;
    foreach (XmlElement element in topm)
    {
    if (element.Name.ToLower() == "appsettings")
    {
    XmlNodeList _node
    = element.ChildNodes;
    if (_node.Count > 0)
    {
    foreach (XmlElement el in _node)
    {
    if (el.Attributes["key"].InnerXml == "IsOpenWin")
    RadioButtonList1.SelectedValue
    = el.Attributes["value"].Value;
    }
    }
    }
    }
    }
    }

    protected void Button1_Click(object sender, EventArgs e)
    {
    string sFile = Server.MapPath("../Web.config");
    XmlDocument xmldoc
    = new XmlDocument();
    xmldoc.Load(sFile);

    XmlNodeList topm
    = xmldoc.DocumentElement.ChildNodes;
    foreach (XmlElement element in topm)
    {
    if (element.Name.ToLower() == "appsettings")
    {
    XmlNodeList _node
    = element.ChildNodes;
    if (_node.Count > 0)
    {
    foreach (XmlElement el in _node)
    {
    if (el.Attributes["key"].InnerXml == "IsOpenWin")
    el.Attributes[
    "value"].Value = RadioButtonList1.SelectedValue;
    }
    }
    }
    }
    xmldoc.Save(sFile);
    Common.Message(
    "<script>alert('修改成功');location.href='Admin_Basic.aspx'</script>");
    }
    }
  • 相关阅读:
    NLog简单配置与使用
    C#将类对象转换为字典
    .net中RSA加密解密
    .net引用System.Data.SQLite操作SQLite
    mongodb的安装以及客户端
    web api 二
    c语言中字符串的存储方式(转)
    cjson两种数组的解析方法(转)
    RT-Thread 自动初始化详解
    RTT与NRF52832移植问题记录
  • 原文地址:https://www.cnblogs.com/hateyoucode/p/1761925.html
Copyright © 2011-2022 走看看