-----Original Message-----
From: dotnet discussion [mailto:[EMAIL PROTECTED]]On Behalf Of
Kerry Whelan
Sent: Thursday, May 16, 2002 9:26 AM
To: [EMAIL PROTECTED]
Subject: [DOTNET] Accessing and editing the web.config file


> I am trying to edit different sections of the web.config file. I can gain
> access to configSections that I have defined using
> ConfigurationSettings.GetConfig(People/owner) in my code

Kerry,
        The web.config (and exename.config) file is an XML file, so you can load
the XML file using the classes in the System.Xml namespace.  I am typing
this into the email editor (don't have .NET loaded on this machine), but
here is the general idea.

        XmlDocument doc = New XmlDocument();
        doc.load(Server.Mappath("web.config"));
        XmlAttribute ownerName =
(XmlAttribute)doc.SelectSingleNode("config/People/owner/@name[.='Joe']");
        ownerName.NodeValue = "Bob";

Kirk Allen Evans
"XML and ASP.NET", New Riders Publishing
Available at Amazon.com
http://www.amazon.com/exec/obidos/ASIN/073571200X

You can read messages from the DOTNET archive, unsubscribe from DOTNET, or
subscribe to other DevelopMentor lists at http://discuss.develop.com.

Reply via email to