简体   繁体   English

使用XNodeEqualityComparer或XElement.DeepEquals来比较xml对象是否更好?

[英]Is it better to use XNodeEqualityComparer or XElement.DeepEquals to compare xml objects?

I need to compare two xml documents. 我需要比较两个xml文档。

Assume that each of the following XElement's load from a Stream : 假设以下每个XElement从Stream加载:

XElement actualElement = XElement.Load(actual);
XElement expectedElement = XElement.Load(expected);

Using that, which of the following two is better: 使用它,以下哪两个更好:

XNodeEqualityComparer comparer = new XNodeEqualityComparer();
comparer.Equals(actualElement, expectedElement);

or 要么

XElement.DeepEquals(actualElement, expectedElement);

I know that the second option is shorter, but I am more interested in whether or not you get any speed improvements or better/deeper comparison when using one or the other. 我知道第二个选项更短,但我更感兴趣的是你在使用其中一个时是否获得任何速度提升或更好/更深的比较。 The comparison itself needs to compare the elements, attributes, and all values between the two xml documents. 比较本身需要比较两个xml文档之间的元素,属性和所有值。

The XNodeEqualityComparer.Equals method simply calls the XNode.DeepEquals method . XNodeEqualityComparer.Equals方法只调用XNode.DeepEquals方法 So there is no difference between the two calls. 所以这两个电话没有区别。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM