changing the xml

V

Vinki

I have this xml file below, I want to change the value of debug to false.
How can I do this in C# or VB.net. I want to do it by selectSingleNode , if
possible.




<?xml version="1.0"?>
<configuration>
<configSections>
<section name="dataConfiguration"
type="Microsoft.Practices.EnterpriseLibrary.Data.Configuration.DatabaseSettings, Microsoft.Practices.EnterpriseLibrary.Data" />
</configSections>
<connectionStrings>

</connectionStrings>
<appSettings>
<add key="connectionString" value="sita" />

</appSettings>
<compilation debug="true">

</compilation>
<!--<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Data.OracleClient"
publicKeyToken="B77A5C561934E66" culture="neutral"/>
<bindingRedirect oldVersion="0.0.0.0-2.0.0.0" newVersion="2.0.0.0"/>
</dependentAssembly>
</assemblyBinding>
</runtime>-->
</configuration>

Any help will be appreacitaed


Thanks.
 
M

Morten Wennevik [C# MVP]

Hi Vinki,

Once you have loaded the xml into an XmlDocument simply do

XmlNode node = doc.SelectSingleNode("/configuration/compilation");
node.Attributes["debug"].Value = "false";
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top