ibdatx 0 Light Poster

Hi,

I have a WPF program written in C# that updates an Xml file from a textbox when a submit button is clicked. The code works as I can tell that the xml file is updated after the execution of the program, however I would like the update in real time not after closing the executable window. Any suggestions would be great. Thanks.

Here is the code for the submit button:

private void Button1_Click(object sender, RoutedEventArgs e)
    {
        XmlDocument doc = new XmlDocument();
        doc.Load("Recipe.xml");
        XmlNode root = doc.DocumentElement;

        XmlElement recipeType = doc.CreateElement("recipeType");
        XmlElement description = doc.CreateElement("description");
        XmlElement recipeInfo = doc.CreateElement("recipeInfo");
        XmlElement name = doc.CreateElement("name");

        name.InnerText = rName.Text;

        if (rType.Text == "Breakfast")
        {
            root.ChildNodes[0].ChildNodes[0].ChildNodes[0].ChildNodes[0].InnerText = rName.Text;
            //code to link the textbox texts to xml
        }
        doc.Save("Recipe.xml");
    }
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.