Reloading an XML during runtime

tarnigree

New Member
I'm loading an xml file into a gantt chart and a scheduler which works fine. Once it's loaded the user can make changes, but in order for the scheduler to show the changes I added an update button. Once the button is hit I take the current data in my gantt chart and save it as an XML to update it, but when I try to reload it I get an \[code\]ArgumentNullException was unhandled\[/code\] error message saying: \[code\]paramerter name: attribute is null\[/code\].I don't know if I have to add something else or if it wont work at runtime since when I take the initial load out of the program I still get this error.\[code\] XElement allData1 = XElement.Load(fileName); var query = allData1.Descendants("task") .Select(task => new { Name = (string)task.Attribute("name"), Start = (DateTime)task.Attribute("start"), Finish = (DateTime?)task.Attribute("finish"), Duration = (long?)task.Attribute("duration"), }); foreach (var item in query) { Appointment app; app = c1Schedule1.DataStorage.AppointmentStorage.Appointments.Add(); app.Subject = item.Name; app.Start = item.Start; if (item.Finish != null) { app.End = item.Finish.Value; } if (item.Duration != null) { app.End = item.Start.AddDays(item.Duration.Value); } }\[/code\]
 
Back
Top