Is there an easy way to compare if 2 XDocuments are equal ignoring element/attribute order?

后端 未结 3 1954
栀梦
栀梦 2021-01-03 22:33

Unit testing my serialization code I found one failed because I had attributes listed in a different order (I\'m just comparing the XDocument.ToString() values) and while I

3条回答
  •  离开以前
    2021-01-03 22:56

    XNode has a DeepEquals function that should do the trick.

    http://msdn.microsoft.com/en-us/library/system.xml.linq.xnode.deepequals.aspx

    Update:

    It appears that the DeepEquals function doesn't always work correctly. You may be best off implementing your own comparison routine.

    http://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=400469

提交回复
热议问题