BoxerBootieHamburgler
New Member
I have a xml file in ClientBin folder with the name XMLFile1.xml.There are three nodes in file:\[code\]<?xml version="1.0" encoding="utf-8" ?><People> <Person FirstName="Ram" LastName="Sita"/> <Person FirstName="Krishna" LastName="Radha"/> <Person FirstName="Heer" LastName="Ranjha"/></People>\[/code\]I can read nodes from file like that:\[code\] public class Person { public string FirstName { get; set; } public string LastName { get; set; } }private void Button_Click_1(object sender, RoutedEventArgs e){ Uri filePath = new Uri("XMLFile1.xml", UriKind.Relative); WebClient client1 = new WebClient(); client1.DownloadStringCompleted += new DownloadStringCompletedEventHandler(client1_DownloadStringCompleted); client1.DownloadStringAsync(filePath);} void client1_DownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e) { if (e.Error == null) { XDocument doc = XDocument.Parse(e.Result); IEnumerable<Person> list = from p in doc.Descendants("Person") select new Person { FirstName = (string)p.Attribute("FirstName"), LastName = (string)p.Attribute("LastName") }; DataGrid1.ItemsSource = list; } }\[/code\]But i cant append node to this. What i have done yet with XDocument and XMLDocument gave me compile errors. Thanks.Update : For example I have tried something like that:string FirstName = "Ferhad"; string LastName = "Cebiyev";\[code\] XDocument xmlDoc = new XDocument(); string path = "C:\\Users\\User\Desktop\\temp\\SilverlightApplication3\\SilverlightApplication3.Web\\ClientBin\\XMLFile1.xml"; xmlDoc.Load(path); xmlDoc.Add(new Person { FirstName=FirstName, LastName = LastName}); xmlDoc.Save(path);\[/code\]