Hi I have the following class which provides access to a xml file:
public class AppConfig
{
public string AppConfigPath = "~/admin.config.xml";
XmlDocument SiteConfig = new XmlDocument();
public string getAppConfigParam(string param)
{
SiteConfig.Load(HttpContext.Current.Server.MapPath(AppConfigPath));
string reqParam = SiteConfig.SelectSingleNode("//cmsAppConfig")[param].InnerText;
return reqParam;
}
public void setAppConfigParam(string paramTitle, string paramValue)
{
SiteConfig.Load(HttpContext.Current.Server.MapPath(AppConfigPath));
XmlNodeList ConfigNodes = SiteConfig.SelectSingleNode("//cmsAppConfig").ChildNodes;
foreach (XmlNode node in ConfigNodes)
{
if (node.Name == paramTitle)
{
node.InnerText = paramValue;
}
}
SiteConfig.Save(HttpContext.Current.Server.MapPath(AppConfigPath));
HttpContext.Current.Response.Redirect(HttpContext.Current.Request.RawUrl);
}
}
I am using the class in the following event to update some app settings but only the first node which is the globalskin gets updated.
protected void btnSaveAppConfig_Click(object sender, EventArgs e)
{
if (IsValid) {
AppConfig myAppConfig = new AppConfig();
myAppConfig.setAppConfigParam("globalskin", drpAppTheme.SelectedValue.ToString());
myAppConfig.setAppConfigParam("homefeedsurl", txtNewsFeedUrl.Text.Trim());
myAppConfig.setAppConfigParam("homefeedstitle", txtNewsFeedTitle.Text.Trim());
}
}
What changes to do I need to make to make the change to all fields? Thank you for your time.