Question : Editing a single value in XML file from a windows Form application c#

Hi,

Am using VS2008, I've a c# windows form app and I am loading info from my XML file into various text boxes on the form. (this bit is working) I need to be able to edit one of the text boxes and have this change updated to the XML file. I've had a go at this but, the file doesn't change. (I'm very new to xml, 1 day) My XML file format is similar to the following:


<?xml version="1.0" encoding="utf-8"?>
<Lessons>
  <Lesson ID =" 01">
    <ButtonName>btnLesson01</ButtonName>
    <Title>Lesson One</Title>
    <Description>This will recreate etc etc </Description>
    <Points>1</Points>
  </Lesson>
  <Lesson ID =" 02">
    <ButtonName>btnLesson02</ButtonName>
    <Title>Lesson Two</Title>
    <Description>This will etc etc </Description>
    <Points>9</Points>
  </Lesson>
  <Lesson ID =" 03">
    <ButtonName>btnLesson03</ButtonName>
   <Title>Lesson Three</Title>
    <Description>This will etc etc </Description>
    <Points>4</Points>
  </Lesson>
  <Lesson ID ="04">
    <ButtonName>btnLesson04</ButtonName>
   <Title>Lesson Four</Title>
    <Description>This will etc etc </Description>
    <Points>10</Points>
  </Lesson>
</Lessons>



My attached code isn't updating the Points element though.
lessonID   in   XmlNode nodeToEdit = doc.SelectSingleNode("/Lessons/Lesson[@ID="+lessonID+"]");    is a string which I assign a value to elsewhere.

Any idea? Thanks




1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
XmlReader reader = XmlReader.Create(FILE_NAME);
            XmlDocument doc = new XmlDocument();
            doc.Load(reader);
       
            XmlNode nodeToEdit = doc.SelectSingleNode("/Lessons/Lesson[@ID="+lessonID+"]");
              if (nodeToEdit != null)
              {
                  nodeToEdit["Points"].InnerText = txtPoints.Text;
                  
              }
              doc.Save("FILE_NAME");
              doc = null;

Answer : Editing a single value in XML file from a windows Form application c#

There is an upgrade package available but it upgrades the entire installation.  They strongly recommend that you backup everything before using it.
http://www.apachefriends.org/en/xampp-windows.html

Upgrading only PHP from a standard PHP package may not work.  XAMPP typically is installed in it's own directories that are different from what a plain PHP installation usually uses.  The ini files are also in a different location.  And there are registry entries for the installations.
Random Solutions  
 
programming4us programming4us