I am trying to update the XML file using dataset, but it creates new node for the new values. below is the code.
private void on(object sender, EventArgs e)
{
try
{
DateTime currTime = DateTime.Now;
DateTime runDate, runTime;
XmlDataDocument xmldoc = new XmlDataDocument(dsTasks1);
foreach (DataRow dRow in dsTasks1.Tables["Job"].Rows)
{
runDate = Convert.ToDateTime(dRow["NextRunDate"]);
currTime.CompareTo(runDate);
runTime = Convert.ToDateTime(dRow["NextRunTime"]);
if ((currTime.ToLocalTime() >= runTime.ToLocalTime()) & (currTime >= runDate))
{
string exePath = dRow["Source"].ToString();
Launcher Launch = new Launcher(exePath);
new Thread(new ThreadStart(Launch.runApp)).Start();
dRow.BeginEdit();
dRow["NextRunDate"] = "3/12/2009";
dRow["NextRunTime"] = "11:00:00 AM";
dRow["Status"] = "Complete";
dRow.EndEdit();
dRow.AcceptChanges();
dsTasks1.AcceptChanges();
xmldoc.save(fs);

Stefan138 reputationPosted Mar 12, 2009, 11:22 AM EDT
You're better off using linq to xml, rather than using a dataset.
It's easier, faster, and a lot easier to write the data the way you want.
Prashanth5 reputationPosted Mar 12, 2009, 11:32 AM EDT
Hi Steve,
I never used linq can you give any basic example like how to search and edit the xml file.
Regards
Prashanth
Vimal KandasamyRank #2,151 · 661 reputationPosted Mar 12, 2009, 8:31 PM EDT
hi
pls see my article...it may help you to update xml data.
Prashanth5 reputationPosted Mar 16, 2009, 5:46 AM EDT
Thanks Vimal,
This article helped me understand the basics of XML. One more query how to use the schema file to do validation of XML file.
Regards,
Prashanth
Vimal KandasamyRank #2,151 · 661 reputationPosted Mar 18, 2009, 10:06 PM EDT
xml validation 1
xml validation 2
it may help you.