I have an XmlDocument that already exists and is read from a file.
I would like to add a chunk of Xml to a node in the document. Is there a good way to create and a
None of this was working for me so i played around abit and here is my solution.
First load up a text field(you can put it to visible = false in public version) load the data in to the text field like so.
string Path = Directory.GetCurrentDirectory() + "/2016";
string pathFile = Path + "/klanten.xml";
StreamReader sr = new StreamReader(pathFile);
txt.Text = sr.ReadToEnd();
sr.Close();
on the save button load up the text field en save it. Dont forget u will have to refresh the text field after that, if u want to add multiple addresses/names, i have not included that part.
string name = Globals.s_Name;
string klanten = txt.Text;
string s = klanten;
XmlDocument xdoc = new XmlDocument();
string klant = "" + naamBox1.Text + " ";
xdoc.LoadXml(s);
XmlDocumentFragment xfrag = xdoc.CreateDocumentFragment();
xfrag.InnerXml = klant;
xdoc.DocumentElement.FirstChild.AppendChild(xfrag);
xdoc.Save(name + "/klanten.xml");