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>");
    }
    }
  • 相关阅读:
    mysql数据引擎
    R语言入门
    springboot整合springmvc、mybatis
    svn搭建和配置
    UML常用图的几种关系的总结
    cookies和session机制
    Java总结篇系列:Java多线程(三)
    Java总结篇系列:Java多线程(一)
    Java总结篇系列:Java多线程(二)
    restframework之认证
  • 原文地址:https://www.cnblogs.com/hateyoucode/p/1761925.html
Copyright © 2011-2022 走看看