Hi, I am trying to develop a program to read through this xml file 'config.xml' and I have specific portions of the file that the user can edit and save. I have been searching everywhere for some help on reading to and from and writing to and saving childnodes from user input.
This is where I last left on and it's just a bunch of random things I tried after trying to gather information. Any help I would appreciate thanks for the help in advanced.
private void button2_Click(object sender, EventArgs e)
{
XmlDocument doc = new XmlDocument();
doc.LoadXml(config.DesktopConfig);
//XPathDocument doc = new XPathDocument(config.DesktopConfig);
XPathNavigator nav = doc.CreateNavigator();
XmlNamespaceManager mgr = new XmlNamespaceManager(nav.NameTable);
mgr.AddNamespace("default", config.DesktopConfig);
XPathNodeIterator interator = nav.Select("//default:MOUSE[@SENSITIVITY]", mgr);
while (interator.MoveNext())
{
interator.Current.GetAttribute("SENSITIVITY", textBox6.Text);
doc.Save(config.DesktopConfig.ToString());
}
/*
XmlDocument docc = new XmlDocument();
docc.Load(config.DesktopConfig);
XmlNodeList sensitivityfile = docc.GetElementsByTagName("SENSITIVITY");
foreach (XmlNode node in sensitivityfile)
{
XmlElement sensitivityelement = (XmlElement) node;
string SENSITIVITY = sensitivityelement.GetElementsByTagName("SENSITIVITY")[0].InnerText;
if (sensitivityelement.HasAttributes)
{
SENSITIVITY = sensitivityelement.Attributes["SENSITIVITY"].InnerText;
}
textBox6.Text = "{0} \n" + SENSITIVITY;
}
*/
/*
XmlDocument sDoc = new XmlDocument();
sDoc.LoadXml(config.DesktopConfig);
XmlNodeList sen = sDoc.SelectNodes("/MOUSE/SENSITIVITY");
foreach (XmlNode s in sen)
{
gunz_config_editor.Mouse sensitivity = new Mouse();
sensitivity.SENSITIVITY = s["SENSITIVITY"].InnerText;
textBox6.Text = sensitivity.SENSITIVITY;
}
*/
}
This is also part of the GUI that this button is for. The node I'm trying to edit is as such (this child nodes are part of two different nodes which is where I'm having some trouble):
<MOUSE>
<SENSITIVITY>0.405200</SENSITIVITY>
<INVERT>FALSE</INVERT>
</MOUSE>
<JOYSTICK>
<SENSITIVITY>0.986000</SENSITIVITY>
<INVERT>FALSE</INVERT>
</JOYSTICK>
The one that I want to edit and access is the MOUSE Sensitivity one
[IMG]http://i52.tinypic.com/292uvqc.jpg[/IMG] <-- GUI part