This project is read-only.


There are three Nuget packages available:

  1. XmlSpecificationCompare - A binary package containing all the code: the XML static comparer (XmlSpecificationEquality), XPath discovery and NUnit support.
  2. XmlSpecificationCompare.Code - A code package containing the XmlSpecificationEquality and related files.
  3. XPathDiscovery.Code - A code package containing the XNode.GetXPath() extension method.

Using XmlSpecificationEquality

Simply call one of the static AreEqual overloaded methods. AreEqual can compare between two XElement objects that represent the root of the XML document or two strings. In the later case the strings are parsed into XDocument objects:

const string xmlA = 
@"<?xml version=""1.0"" encoding=""UTF-8""?>
  <a:root xmlns:a=""""/>";

const string xmlB = 
@"<?xml version=""1.0"" encoding=""UTF-8""?>
  <root xmlns="""">

var result = XmlSpecificationEquality.AreEqual(xmlA, xmlB);
if (!result.Success)
   Console.Writeline("Compare failed at " + result.FailObject.GetXPath()); 

Using XPath Discovery

XPath discovery is provided by the XpathExtension class which defines the XObject extension method GetXPath() which returns a simple XPath to the XObject in question. For a usage example look at the second to last line in the example above.

The only types of XObject currently supported are:

  • XElement
  • XAttribute
  • XText
  • XCData
  • XComment

Using NUnit Integration

Simple Assertion:


Assert.That(xmlA, XmlIs.SpecificationEquals(xmlB))


Complex Assertion:


Assert.That(xmlA, Is.Not.XmlEquals(xmlB));
Assert.That(xmlList, Is.All.XmlEquals(xmlB))


Last edited Feb 19, 2015 at 1:56 AM by Eli_A, version 2


No comments yet.