hi to all,
I want to How to two xml files data comaire and mitchmatch data show in excel file.
i am using this code
private void btnCompaire_Click(object sender, RoutedEventArgs e) { List fileslist = new List(); var list = new List>(); //string[] finaltxtfiledata; // KeyValuePair finallist = new KeyValuePair(); if (File.Exists(txtpath)) { string[] LinesinText = File.ReadAllLines(txtpath); fileslist.Add(LinesinText[0]); fileslist.Add(LinesinText[1]); } string[] Linesin1 = File.ReadAllLines(fileslist[0]); string[] Linesin2 = File.ReadAllLines(fileslist[1]); bool areEqual = Linesin1pcfg.SequenceEqual(Linesin2pcfg); int onecount = Linesin1.Count(); int twocount = Linesin2.Count(); int finalcount; if (onecount > twocount) { finalcount = onecount; } else { finalcount = twocount; } if (!areEqual) { for (int i = 0; i < finalcount; i++) { try { if (Linesin1pcfg[i] != null && Linesin2[i] != null) { if (Linesin1pcfg[i].Equals(Linesin2[i])) { //.Application oExcel = new Microsoft.Office.Interop.Excel.Application(); //Excel._Workbook oWorkBook; //Excel._Worksheet oSheet; Microsoft.Office.Interop.Excel.Application xlApp = new Microsoft.Office.Interop.Excel.Application(); if (xlApp != null) { // xlApp.Visible = true; string workbookPath = Linesin1[i]; Microsoft.Office.Interop.Excel.Application excelApp = new Microsoft.Office.Interop.Excel.Application(); Microsoft.Office.Interop.Excel.Workbook excelWorkbook = excelApp.Workbooks.Open(workbookPath); Microsoft.Office.Interop.Excel.Worksheet sheet = excelWorkbook.Sheets["Sheet1"] as Microsoft.Office.Interop.Excel.Worksheet; if (sheet == null) return; Microsoft.Office.Interop.Excel.Range range = sheet.get_Range("A1", Missing.Value); var yourValue = range.Text; } } else { list.Add(new KeyValuePair(Linesin1[i], Linesin2[i])); } } } catch (Exception) { continue; } } } }
In this code i am getting value :
xaml file path in TextFile : like C:\Desktop\abc.xml
C:\Desktop\xyz.xml
In Both files contaion some data like abc.xml file contaion 150 lines & xyz.xml file contain 200 lines of xml code.
Getting data of both files
string[] Linesin1 = File.ReadAllLines(fileslist[0]); string[] Linesin2 = File.ReadAllLines(fileslist[1]);
Now i want to how to compaire data of both files and show in a EXCEL file.
Mismatch xml data show on EXCEL file.
Thanks.