0
Each ComboBoxItem has a tag property; when loading the ComboBox, set the tag of each item to the corresponding XML node, then when a ComboBoxItem changes, just cast the tag property back to a XML node object.
0
You can use the foreach loop also in the following way.
XmlDocument xmldoc = new XmlDocument();
xmldoc.Load ("Filename");
XmlNode node = xmldoc.DocumentElement;
foreach(XmlNode testConfig in node.ChildNodes)
{
foreach (XmlNode TbleItem in testConfig.ChildNodes)
{
//Write the code to find out the thing you want to change
if(TbleItm.innertext == "Name of the tag whose innertext u want to change")
TbleItm.innertext = "The value";
}
}
Hope this will make the thing easy for you.
0
I meant to change a single nodes innertext... I think I found a way to do it.
<Test.MyConfiguration>
<tableItem >
<upperRow>
<item>First</item>
<item>Second</item>
</upperRow>
</tableItem>
</Test.MyConfiguration>
XmlNode newNode = rootNode.SelectSingleNode("//upperRow/item[0]");
newNode.InnerText = "firstItem";
Using this syntax I can change the innertext of only the first item. (Since I only wanted to change certain singular nodes)
<Test.MyConfiguration>
<tableItem >
<upperRow>
<item>firstItem</item>
<item>Second</item>
</upperRow>
</tableItem>
</Test.MyConfiguration>
0
Think following as your XML file...
<?xml version="1.0" encoding="utf-8" ?>
<Test.MyConfiguration>
<tableItem >
<upperRow>
<item>First</item>
<item>Second</item>
</upperRow>
</tableItem>
</Test.MyConfiguration>
// This is how you can load your XML file...
private void LoadXmlDocument()
{
try
{
String filePath = @"C:/abc.xml";
XmlTextReader reader = new XmlTextReader(filePath);
doc.Load(reader);
}
catch (FileNotFoundException fno)
{
throw;
}
}
To change the value of the innerText... (Ex- Change the value "First" to "Last")
XmlNode xmlNode = doc.DocumentElement;
if (xmlNode != null)
{
XmlNodeList nodes = xmlNode.ChildNodes;
for (int i = 0; i < nodes.Count; i++)
{
if (nodes[i].ChildNodes[0].HasChildNodes)
{
for (int j = 0; j < nodes[i].ChildNodes[0].ChildNodes.Count; j++)
{
nodes[i].ChildNodes[0].ChildNodes[j].InnerText = dropdown.SelectedItem.ToString();
}
}
}
}
Hope you will get good results using this.
Good Luck!!!
Regards,
Lakitha Munasinghe