我有两个xml输入
<Key>
<PropertyRef Name="id"></PropertyRef>
</Key>
和
<Key>
<PropertyRef Name="id" />
</Key>
在我看来,它们在语义上是相同的。但是XNode.DeepEquals
返回false
以下是用于比较的代码
class Program
{
static void Main(string[] args)
{
while (true)
{
Console.WriteLine("Press any key to continue");
Console.ReadKey();
string expected = File.ReadAllText(@"<<pathtofirstfile>>");
string actual = File.ReadAllText(@"<<pathtosecondfile>>");
var expectedResponse = GetXmlElement(expected);
var actualResponse = GetXmlElement(actual);
Console.WriteLine(XNode.DeepEquals(expectedResponse, actualResponse));
}
}
private static XElement GetXmlElement(string text)
{
var actualResponse = XElement.Parse(text);
return actualResponse;
}
}