How can I configure XmlUnit.Net to ignore the XML declaration when comparing two documents?
Assume I have the following control document:
<?xml version="1.0" encoding="utf-8"?>
<a><amount>1</amount></a>
Which I want to compare with:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<a><amount>1</amount></a>
The comparison should result in no differences.
My expectation would be that using a NodeFilter like so should work, but it doesn't:
var diff = DiffBuilder.Compare(control)
.WithTest(test)
.WithNodeFilter(n => n.NodeType != XmlNodeType.XmlDeclaration)
.Build();
diff.Differences.Count().Should().Be(0);
The assertion fails with two differences - one for the encoding (different casing) and another for the standalone attribute. I'm not interested in any.
Whether I say n.NodeType != XmlNodeType.XmlDeclaration
or n.NodeType == XmlNodeType.XmlDeclaration
makes no difference.
I am using XMLUnit.Core v2.5.1.