I am currently struggling with an issue when comparing 2 xmls - original and reference for differences. The trouble is when I try to apply wildcards for comparison with different child order - additionaly those childs may have different number of attributes in a node so the comparison is even harder.
I tried to implement a solution using XMLUnit & XMLDiff libraries for .NET but without any success.
using System;
using Org.XmlUnit.Builder;
using Org.XmlUnit.Diff;
using System.IO;
static void Main(string[] args)
{
string orgFilePath = @"C:\Temp\original.xml";
string refFilePath = @"C:\Temp\reference.xml";
StreamReader orgStreamReader = new StreamReader(orgFilePath);
StreamReader refStreamReader = new StreamReader(refFilePath);
String orgFile = XDocument.Load(orgStreamReader).ToString();
String refFile = XDocument.Load(refStreamReader).ToString();
var diff = DiffBuilder
.Compare(Input.FromString(orgFile))
.WithTest(Input.FromString(refFile))
.CheckForSimilar()
.Build();
foreach (var d in )
{
Console.WriteLine(d.Comparison);
Console.WriteLine();
}
Console.WriteLine(diff.Differences);
Console.ReadLine();
}
ref file:
<deviceOrders>
<deviceOrder>
<operation>New</operation>
<moduleId>*</moduleId>
<net>TST</net>
<sort>VT</sort>
<moduleNr>220</moduleNr>
<deviceNr>0</deviceNr>
</deviceOrder>
<deviceOrder>
<operation>New</operation>
<moduleId>*</moduleId>
<net>79ST</net>
<sort>UP</sort>
<deviceNr>0</deviceNr>
</deviceOrder>
</deviceOrders>
org file:
<deviceOrders>
<deviceOrder>
<operation>New</operation>
<moduleId>1235</moduleId>
<net>79ST</net>
<sort>UP</sort>
<deviceNr>0</deviceNr>
</deviceOrder>
<deviceOrder>
<operation>New</operation>
<moduleId>1234</moduleId>
<net>TST</net>
<sort>VT</sort>
<moduleNr>220</moduleNr>
<deviceNr>0</deviceNr>
</deviceOrder>
</deviceOrders>
I didn't find solution yet so please help me with that.