I'm trying to load an xml file into a dataset, then load the same xml
file with a slight change into a second dataset, then do a merge to
see what changed between datasets.
DataSet xmlDataSet = new DataSet("Origin al");
xmlDataSet.Read Xml("C:\\temp\\ a.xml");
xmlDataSet.Acce ptChanges();
PrintValues(xml DataSet, "Original") ;
DataSet xml2 = new DataSet("New");
xml2.ReadXml("C :\\temp\\b.xml" );
xml2.AcceptChan ges();
PrintValues(xml 2, "New");
xmlDataSet.Merg e(xml2);
DataSet DSChanges = new DataSet("change ");;
DSChanges = xmlDataSet.GetC hanges();
DSChanges.Accep tChanges();
PrintValues(DSC hanges, "Changes");
public static void PrintValues(Dat aSet ds, string label)
{
Console.WriteLi ne("\n" + label);
foreach(DataTab le t in ds.Tables)
{
Console.WriteLi ne("TableName: " +
t.TableName);
foreach(DataRow r in t.Rows)
{
foreach(DataCol umn c in t.Columns)
{
Console.Write(" \t " + r[c] );
}
Console.WriteLi ne();
}
}
}
XML file A:
<?xml version="1.0"?>
<sheet title="mytitle" >
<section title="General" ></section>
<section title="Processo r"></section>
</sheet>
XML file B:
<?xml version="1.0"?>
<sheet title="mytitle" >
<section title="General1 "></section>
<section title="Processo r"></section>
</sheet>
I'm doing an Acceptchanges after reading both files to change the row
state to unchanged instead of added. Because if I didn't when I do
the merge, all rows would be Added. I just want to pull the
changes. Pretty much comparing the two datasets and getting the
differences.
Thanks for your help.
Posted Via Usenet.com Premium Usenet Newsgroup Services
----------------------------------------------------------
** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
----------------------------------------------------------
http://www.usenet.com