Find difference between two custom list objects
public class details { public string classname; public list<student> studentcollection; } public class student { public string rollnumber, name; public list<marks> studentmarks; } public class marks { public string eng, maths, term; }
old xml ---------- <details> <class>1.0</class> <student rollnumber="001" name="aaa"> <marks eng="50" maths="50" term="first"/> <marks eng="60" maths="57" term="second"/> <marks eng="55" maths="56" term="third"/> <marks eng="59" maths="85" term="fourth"/> </student> <student rollnumber="002" name="baa"> .... </student> </details> new xml ---------- <details> <class>1.0</class> <student rollnumber="001" name="aaa"> <marks eng="50" maths="60" term="first"/> <marks eng="60" maths="57" term="second"/> <marks eng="55" maths="46" term="third"/> <marks eng="59" maths="85" term="fourth"/> </student> <student rollnumber="002" name="baa"> .... </student> </details>
hi all, using xelement.load have loaded xml above class. class , xml structure given above.
i have requirement have compare 2 xml files. in hte new xml, marks student(s) might change particular term(s).
i need identify student , term eth marks has been chnaged.can u plz let me knwo how difference between tow list<marks> object.
i holding hte object like,
details olddetails = getdetails(path1);
details newdetails = getdetails(path2);
thanks,
put data datable , compare tables shown on webpage below
http://stackoverflow.com/questions/6187140/compare-two-datatable-in-c-sharp
the code below load 2 datatables
using system; using system.collections.generic; using system.linq; using system.text; using system.xml; using system.xml.linq; using system.data; namespace consoleapplication2 { class program { static string input1 = "<details>\n" + "<class>1.0</class>\n" + "<student rollnumber=\"001\" name=\"aaa\">\n" + "<marks eng=\"50\" maths=\"50\" term=\"first\"/>\n" + "<marks eng=\"60\" maths=\"57\" term=\"second\"/>\n" + "<marks eng=\"55\" maths=\"56\" term=\"third\"/>\n" + "<marks eng=\"59\" maths=\"85\" term=\"fourth\"/>\n" + "</student>" + "<student rollnumber=\"002\" name=\"baa\">\n" + "<marks eng=\"50\" maths=\"50\" term=\"first\"/>\n" + "<marks eng=\"60\" maths=\"57\" term=\"second\"/>\n" + "<marks eng=\"55\" maths=\"56\" term=\"third\"/>\n" + "<marks eng=\"59\" maths=\"85\" term=\"fourth\"/>\n" + "</student>\n" + "</details>\n"; static string input2 = "<details>\n" + "<class>1.0</class>\n" + "<student rollnumber=\"001\" name=\"aaa\">\n" + "<marks eng=\"50\" maths=\"60\" term=\"first\"/>\n" + "<marks eng=\"60\" maths=\"57\" term=\"second\"/>\n" + "<marks eng=\"55\" maths=\"46\" term=\"third\"/>\n" + "<marks eng=\"59\" maths=\"85\" term=\"fourth\"/>\n" + "</student>" + "<student rollnumber=\"002\" name=\"baa\">\n" + "<marks eng=\"50\" maths=\"50\" term=\"first\"/>\n" + "<marks eng=\"60\" maths=\"57\" term=\"second\"/>\n" + "<marks eng=\"55\" maths=\"56\" term=\"third\"/>\n" + "<marks eng=\"59\" maths=\"85\" term=\"fourth\"/>\n" + "</student>\n" + "</details>\n"; static void main(string[] args) { xdocument doc; doc = new xdocument(); doc = xdocument.parse(input1); dataset set1 = new dataset(); set1.readxml(doc.createreader()); doc = new xdocument(); doc = xdocument.parse(input2); dataset set2 = new dataset(); set2.readxml(doc.createreader()); } } }
jdweng
Visual Studio Languages , .NET Framework > Visual C#
Comments
Post a Comment