XMLUnit.Core 2.11.1

dotnet add package XMLUnit.Core --version 2.11.1
                    
NuGet\Install-Package XMLUnit.Core -Version 2.11.1
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="XMLUnit.Core" Version="2.11.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="XMLUnit.Core" Version="2.11.1" />
                    
Directory.Packages.props
<PackageReference Include="XMLUnit.Core" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add XMLUnit.Core --version 2.11.1
                    
#r "nuget: XMLUnit.Core, 2.11.1"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#addin nuget:?package=XMLUnit.Core&version=2.11.1
                    
Install XMLUnit.Core as a Cake Addin
#tool nuget:?package=XMLUnit.Core&version=2.11.1
                    
Install XMLUnit.Core as a Cake Tool

XMLUnit.NET

XMLUnit provides you with the tools to verify the XML you emit is the one you want to create.

It provides helpers to validate against an XML Schema, assert the values of XPath queries or compare XML documents against expected outcomes.

This package provides the core functionality and can be used stand-alone. In addition there are libraries providing NUnit constraints and a "placeholders" package that may simplify writing comparison tests in certain cases.

[Build status]

Requirements

XMLUnit requires .NET Standard 2.0 (tested with .NET 8 rigt now) and should still support .NET Framework 3.5 and Mono.

The core library hasn't got any dependencies itself.

Usage

These are some really small examples, more is available as part of the user guide

Comparing Two Documents

ISource control = Input.FromFile("test-data/good.xml").Build();
ISource test = Input.FromByteArray(CreateTestDocument()).Build();
IDifferenceEngine diff = new DOMDifferenceEngine();
diff.DifferenceListener += (comparison, outcome) => {
            Assert.Fail("found a difference: {}", comparison);
        };
diff.Compare(control, test);

or using the fluent builder API

Diff d = DiffBuilder.Compare(Input.FromFile("test-data/good.xml"))
             .WithTest(CreateTestDocument()).Build();
Assert.IsFalse(d.HasDifferences());

Asserting an XPath Value

ISource source = Input.FromString("<foo>bar</foo>").Build();
IXPathEngine xpath = new XPathEngine();
IEnumerable<XmlNode> allMatches = xpath.SelectNodes("/foo", source);
string content = xpath.evaluate("/foo/text()", source);

Validating a Document Against an XML Schema

Validator v = Validator.ForLanguage(Languages.W3C_XML_SCHEMA_NS_URI);
v.SchemaSources = new ISource[] {
        Input.FromUri("http://example.com/some.xsd").Build(),
        Input.FromFile("local.xsd").Build()
    };
ValidationResult result = v.ValidateInstance(Input.FromDocument(CreateDocument()).Build());
bool valid = result.Valid;
IEnumerable<ValidationProblem> problems = result.Problems;

Additional Documentation

XMLUnit.NET is developed at github. More documentation, releases and an issue tracker can be found there.

Changelog

See the Release Notes at github.

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net35 is compatible.  net40 was computed.  net403 was computed.  net45 was computed.  net451 was computed.  net452 was computed.  net46 was computed.  net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

This package has no dependencies.

NuGet packages (6)

Showing the top 5 NuGet packages that depend on XMLUnit.Core:

Package Downloads
XMLUnit.NUnit3.Constraints

This package contains NUnit 3.x Constraints to be used with XMLUnit.NET's core. XMLUnit provides you with the tools to verify the XML you emit is the one you want to create. It provides helpers to validate against an XML Schema, assert the values of XPath queries or compare XML documents against expected outcomes.

XMLUnit.NUnit2.Constraints

This package contains NUnit 2.x Constraints to be used with XMLUnit.NET's core. XMLUnit provides you with the tools to verify the XML you emit is the one you want to create. It provides helpers to validate against an XML Schema, assert the values of XPath queries or compare XML documents against expected outcomes.

XMLUnit.Placeholders

This package contains experimental support for configuring parts of the test engine by using ${xmlunit.KEYWORD} sequences inside the control document.

CESMII.OpcUa.NodeSetDiff

OPC UA Node Set Diffing tool.

ChannelAdam.TestFramework.Xml

A .NET library with functionality for comparing XML (using XmlUnit).

GitHub repositories (2)

Showing the top 2 popular GitHub repositories that depend on XMLUnit.Core:

Repository Stars
dotnet/csharpstandard
Working space for ECMA-TC49-TG2, the C# standard committee.
chummer5a/chummer5a
Character generator for Shadowrun 5th edition
Version Downloads Last updated
2.11.1 5,050 5/19/2025
2.11.0 34,284 3/28/2025
2.10.0 367,259 8/8/2024
2.9.2 1,038,718 3/16/2023
2.9.1 679,551 12/16/2021
2.9.0 4,266,864 10/30/2020
2.8.0 262,341 5/12/2020
2.7.2 233,213 3/8/2020
2.7.1 835,398 6/21/2019
2.7.0 196,934 4/13/2019
2.7.0-beta-01 2,226 4/10/2019
2.6.0 219,717 4/22/2018
2.5.1 302,821 10/20/2017
2.5.0 40,077 9/3/2017
2.4.0 13,280 7/23/2017
2.3.1 49,390 3/23/2017
2.3.0 56,091 11/12/2016
2.2.0 144,885 6/4/2016
2.1.1 12,713 4/9/2016
2.1.0 3,854 3/26/2016
2.0.0 6,654 3/6/2016
2.0.0-alpha-04 3,968 2/6/2016
2.0.0-alpha-03 3,377 12/12/2015
2.0.0-alpha-02 2,371 11/21/2015