惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

H
Help Net Security
博客园_首页
酷 壳 – CoolShell
酷 壳 – CoolShell
G
Google Developers Blog
Jina AI
Jina AI
C
Check Point Blog
Apple Machine Learning Research
Apple Machine Learning Research
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
GbyAI
GbyAI
Last Week in AI
Last Week in AI
罗磊的独立博客
Hugging Face - Blog
Hugging Face - Blog
阮一峰的网络日志
阮一峰的网络日志
The Cloudflare Blog
M
MIT News - Artificial intelligence
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
J
Java Code Geeks
WordPress大学
WordPress大学
博客园 - 聂微东
月光博客
月光博客
博客园 - 司徒正美
T
The Blog of Author Tim Ferriss
大猫的无限游戏
大猫的无限游戏
Microsoft Security Blog
Microsoft Security Blog

博客园 - hateyoucode

http://tengine.taobao.org/ Mysql只Union用法 比较详细的mysql的几种连接功能分析,只要你看完就能学会的好东西 jq 判断单选是否选中 MSSQL中的bit类型 js 判断textarea 不为空 C# Split 分隔符为字符串及空格的处理 [转]asp.net中时间差的问题 [转]C# Array 数组 及 一些操作 [转]C#中out 及 ref 区别 [转]使用c# 模拟网站登录 RegisterStartupScript和RegisterClientScriptBlock的区别 asp.net 动态二维数组 - hateyoucode - 博客园 asp+ajax asp中ajax的中文乱码 - hateyoucode - 博客园 css html span 块状不换行 我们应该明确几个问题 PHP Header用于页面跳转要注意的几个问题总结 - hateyoucode - 博客园 关于PHP header函数跳转的问题 - hateyoucode - 博客园 生成xml - hateyoucode - 博客园
asp.net操作XML
hateyoucode · 2010-06-21 · via 博客园 - hateyoucode

代码

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>");
}
}