Check if XML element equals another XML element, ignoring empty values



I'm checking if two XML elements given by string are equal with this method:



private static bool XmlEquals(string s1, string s2)
{
return XNode.DeepEquals(XElement.Parse(s1), XElement.Parse(s2));
}


This work unless one of the elements has opening and closing tags and the other has a closed tag like this:



<MyElement SomeAttribute="some value" />
<MyElement SomeAttribute="some value"></MyElement>


Can I somehow compare two XML elements in a way, that the above case is considered equal?


No comments:

Post a Comment