星期零

技术改变生活,分享让我们快乐!
  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

Web.Config配置文件中自定义节点信息的读取

Posted on 2006-08-10 15:00  weekzero  阅读(939)  评论(0)    收藏  举报

有时候我们会在Web.Config配置文件自己定义一些节点来存放我们的信息,下面是一中读取的方法。
如“Web.Config”文件的“<configuration>”下又添加了一个节点,
  <configSections>
    <section name="bestitnet" type="BestItNet.Common.SectionHandler,bestitnet"/>
  </configSections>

现在就是想获得“type”节点上的信息,方法如下:
using System.Xml;    //引用命名空间

XmlDocument doc = new XmlDocument();
doc.Load(Request.PhysicalApplicationPath + "/web.config");
XmlNode node = doc.SelectSingleNode("configuration/configSections/section/@type");
Response.Write(node.Value);