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.
精彩评论