XNode.DeepEquals considers selfclosing tags and closing tags as different

Viewed 462

I want to compare two xml documents to equality. One of my document have self-closing tag and other don't.

XNode node = XDocument.Parse("<Root/>");
XNode node2 = XDocument.Parse("<Root></Root>");

bool result = XNode.DeepEquals(node, node2);
Console.WriteLine(result);

Run it quickly

I assume "<Root/>" is equivalent to "<Root></Root>" however DeepEquals says they are not(returns false).

How can I compare these these two documents to be equal?

ps:Not constrained with XNode. Solution using XmlDocument also welcome.

1 Answers
Related