开发者

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

I need to compare two xml documents.

Assume that each of the following XElement's load from a 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.


The XNodeEqualityComparer.Equals method simply calls the XNode.DeepEquals method. So there is no difference between the two calls.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜