public static bool AreXmlElementsEqual(XmlInput ours, XmlInput theirs) { // Must use 'config', or whitespace only differences will make the elements different. // cf. diffing changeset 240 and 241 in the Tok Pisin project for such whitespace differences. var config = new DiffConfiguration(WhitespaceHandling.None); var diff = new XmlDiff(ours, theirs, config); var diffResult = diff.Compare(); return(diffResult == null || diffResult.Difference == null || !diffResult.Difference.MajorDifference); }
public XmlDiff(XmlInput control, XmlInput test, DiffConfiguration diffConfiguration) { _diffConfiguration = diffConfiguration; _controlReader = CreateXmlReader(control); if (control.Equals(test)) { _testReader = _controlReader; } else { _testReader = CreateXmlReader(test); } }
private XmlReader CreateXmlReader(XmlInput forInput) { XmlReader xmlReader = forInput.CreateXmlReader(); if (xmlReader is XmlTextReader) { ((XmlTextReader)xmlReader).WhitespaceHandling = _diffConfiguration.WhitespaceHandling; } if (_diffConfiguration.UseValidatingParser) { #pragma warning disable 612,618 XmlValidatingReader validatingReader = new XmlValidatingReader(xmlReader); #pragma warning restore 612,618 return(validatingReader); } return(xmlReader); }
public XmlDiff(XmlInput control, XmlInput test) : this(control, test, new DiffConfiguration()) { }