I think a little clarification is required.
Are you:
1. trying to produce 3 XML files? One file for added rows, one for deleted and one for modified?
OR
2. do you want 1 XML file with the complete table but containing an attribute on each row to indicate the added/modified/deleted status?
If it's
1. create 3 new
DataTables
. One each for rows Added/Delete and Modified. Add rows to each table within the conditions in your 1st loop. When you've built the tables call:
dtAdded.WriteXml("MyAddedRows.xml");
dtModified.WriteXml("MyModRows.xml");
dtDeleted.WriteXml("MyDeletedRows.xml");
OR
2. You can't use the
DataTable.WriteXml()
method because the row status is not generated. You'll have to extract all the data from the table and build an XML file yourself using
XmlWriter
.