<?xml version="1.0" encoding="utf-8" ?> <LANGUAGES> <LANGUAGE> <Name>English</Name> <CULTURE>en-US</CULTURE> <Selected>Y</Selected> </LANGUAGE> <LANGUAGE> <Name>German</Name> <CULTURE>de-DE</CULTURE> <Selected>Y</Selected> </LANGUAGE> <LANGUAGE> <Name>Chines</Name> <CULTURE>zh-CN</CULTURE> <Selected>Y</Selected> </LANGUAGE> </LANGUAGES>
private void OnSelectedLanguageChanged(Model.Language selectedLanguage) { XmlDocument doc = new XmlDocument(); doc.Load("Languages.xml"); XmlNodeList aNodes = doc.SelectNodes("/LANGUAGES/LANGUAGE"); // loop through all nodes foreach (XmlNode aNode in aNodes) { XmlAttribute selectedAttribute = aNode.Attributes["Selected"]; // check if that attribute even exists... if (selectedAttribute != null) { // if yes - read its current value string currentValue = selectedAttribute.Value; if (!string.IsNullOrEmpty(currentValue)) { selectedAttribute.Value = "N"; } } } doc.Save(@"Languages.xml"); }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)