adding xmlnodes to a xml-file

Mar 14 2005 12:53 PM
I have some problems adding a node to a xml-file the current xml-file: nl PC_STAGE2 j6FlMJT/yLc= NewbUgfLgZU= PC_STAGE2 winkin name loc I want something like this: The elements have to be added to by using the function AddRecentlyUsed("winking","nowhere" and AddRecentlyUsed("another","here") nl PC_STAGE2 j6FlMJT/yLc= NewbUgfLgZU= PC_STAGE2 winkin name loc nowhere here my current code for the function AddRecentlyUsed: public static void AddRecentlyUsed(string name, string location) { string xadres = "//WinkinSettings/Recently_Used/"; XmlDocument doc = GetLocalSettings(); XmlNode node = doc.CreateNode(XmlNodeType.Element,name,xadres); XmlNode twee = doc.CreateNode(XmlNodeType.Element,location,xadres+name); twee.InnerText=location; node.AppendChild(twee); doc.AppendChild(node); doc.Save(GetLocalSettingsLocation()); MessageBox.Show("added"); } I only get an error with this, saying there is already a document element. It's probably something very dumb and simple, but I don't find get. The mistake is most likely in the doc.CreateNode

Answers (3)