Im pretty n00bish so im sure it's just a dumb mistake I did. But I can't read the xml and then write something on it.

static string LoadXML(String TheParent, String TheChild)
{
System.IO.StreamReader sr = new System.IO.StreamReader(@"SP.xml");
System.Xml.XmlTextReader xr = new System.Xml.XmlTextReader(sr);
System.Xml.XmlDocument SP = new System.Xml.XmlDocument();
SP.Load(xr);
System.Xml.XmlNodeList SPParent = SP.SelectNodes("XMLDoc/" + TheParent);
System.Xml.XmlNode SPChild = SPParent.Item(0).SelectSingleNode(TheChild);
return SPChild.InnerText;
}

public void WriteXML(String TheParent, String TheChild, String TheValue)
{
System.IO.StreamReader sr = new System.IO.StreamReader(@"SP.xml");
System.Xml.XmlTextReader xr = new System.Xml.XmlTextReader(sr);
System.Xml.XmlDocument SP = new System.Xml.XmlDocument();
SP.Load(xr);
System.Xml.XmlNodeList SPParent = SP.SelectNodes("XMLDoc/" + TheParent);
System.Xml.XmlNode SPChild = SPParent.Item(0).SelectSingleNode(TheChild);

System.Xml.XmlTextWriter Writer = new System.Xml.XmlTextWriter(TheValue, System.Text.UTF8Encoding.UTF8);
SP.WriteTo(Writer);
Writer.Flush();
}






private void button1_Click(object sender, EventArgs e)
{
int TestMe = Int32.Parse(LoadXML("Main", "Subjects")) + 1;
WriteXML("Main", "Subjects", TestMe.ToString());
Label1.Text = LoadXML("Main", "Subjects");
}


There are no errors, I can build it and perform the button click just fine. The XML looks like this:

<XMLDoc>
<Main>
<Subjects>3</Subjects>
</Main>
</XMLDoc>



When I call the button click, Label1.Text says there is still 3 for the subject. I also tried:

private void button1_Click(object sender, EventArgs e)
{
int TestMe = 15;
WriteXML("Main", "Subjects", TestMe.ToString());
Label1.Text = LoadXML("Main", "Subjects");
}


And it still shows 3 in Label1.text.