<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
...
<connectionStrings>
...
</connectionStrings>
<applicationSettings>
<Settings>
...
<setting name="ServerConfig" serializeAs="String">
<value>STAGE</value>
</setting>
...
</Settings>
</applicationSettings>
</configuration>
I have the above XML structure, and for testing purposes I'm trying to throw together an app that will change the ServerConfig value element to be a different string (STAGE, PRODUCTION, INTERNAL). I'm unsure how to navigate to and update that value.
Edit:
XmlDocument xml = new XmlDocument();
xml.Load("doc.xml");
foreach (XmlElement element in xml.SelectNodes("setting"))
{
foreach (XmlElement child in element)
{
if (element.SelectSingleNode("value").InnerText == "STAGE")
{
MessageBox.Show(child.InnerText);
}
}
}
This is the code I've been trying to get to work, but can't seem to get the value. I want to be able to select the setting with the name attribute "ServerConfig" and change the value of the value element.