您的位置:首页 > 编程语言 > ASP

asp.net 对 xml webconfig的操作

2008-06-25 22:54 405 查看
XmlDocument xdc = new XmlDocument();

xdc.Load(Server.MapPath("Web.config"));

XmlNode root = xdc.SelectSingleNode("configuration/appSettings/add");

XmlElement xe = root as XmlElement;

xe.SetAttribute("value","server=.;database=pubs;user id=sa;password=");

xe.InnerText="tesstadd";

xdc.Save(Server.MapPath("Web.config"));

Response.Write(xe.GetAttribute("key"));

Dim xdc As XmlDocument = New XmlDocument

xdc.Load(Request.PhysicalApplicationPath + ("web.xml"))

Dim xn As XmlNode = xdc.SelectSingleNode("root/config/pc")

Dim xe As XmlElement = CType(xn, XmlElement)

xe.GetAttribute("name")

xe.GetAttribute("ip")

xe.GetAttribute("open")

Dim ip As String = xe.GetAttribute("ip")

Dim open As String = xe.GetAttribute("open")

If open = "yes" Then

Else

Response.Redirect(Request.Url.ToString())

End If
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐