XmlSerializerHelper 5.0.7-pre

This is a prerelease version of XmlSerializerHelper.
There is a newer version of this package available.
See the version list below for details.
dotnet add package XmlSerializerHelper --version 5.0.7-pre
                    
NuGet\Install-Package XmlSerializerHelper -Version 5.0.7-pre
                    
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="XmlSerializerHelper" Version="5.0.7-pre" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="XmlSerializerHelper" Version="5.0.7-pre" />
                    
Directory.Packages.props
<PackageReference Include="XmlSerializerHelper" />
                    
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 XmlSerializerHelper --version 5.0.7-pre
                    
#r "nuget: XmlSerializerHelper, 5.0.7-pre"
                    
#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.
#:package XmlSerializerHelper@5.0.7-pre
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=XmlSerializerHelper&version=5.0.7-pre&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=XmlSerializerHelper&version=5.0.7-pre&prerelease
                    
Install as a Cake Tool

XmlSerializerHelper

Version Downloads Buy Me a Coffee

<img src="https://raw.githubusercontent.com/thomasgalliker/XmlSerializerHelper/master/logo.png" width="100" height="100" alt="XmlSerializerHelper" align="right">

XmlSerializerHelper serializes and deserializes any .NET object from/to XML. It internally uses XmlSerializer which is part of the System.Xml.Serialization namespace. On top of XmlSerializer it adds a feature to preserve original type information.

Download and Install XmlSerializerHelper

This library is available on NuGet: https://www.nuget.org/packages/XmlSerializerHelper Use the following command to install XmlSerializerHelper using NuGet package manager console:

PM> Install-Package XmlSerializerHelper

You can use this library in any .NET Standard or .NET project.

API Usage

Serializing a .NET object to XML

The following unit test shows how a simple .NET object of type SimpleSerializerClass is serialized to XML:

// Arrange
IXmlSerializerHelper xmlSerializerHelper = new XmlSerializerHelper();
var obj = new SimpleSerializerClass { BoolProperty = true, StringProperty = "test" };
Type targetType = obj.GetType();

// Act
string serializedString = xmlSerializerHelper.SerializeToXml(obj);

// Assert
serializedString.Should().NotBeNullOrEmpty();
Deserialize an XML string to a .NET object

The following unit test shows the above serializedString can be deserialized again:

// Arrange
// ...

// Act
var deserializedObject = (SimpleSerializerClass)xmlSerializerHelper.DeserializeFromXml(targetType, serializedString);

// Assert
deserializedObject.Should().NotBeNull();
deserializedObject.BoolProperty.Should().BeTrue();
deserializedObject.StringProperty.Should().Be("test");
Validate the XSD schema for an XML file

XsdValidator can be used to validate XML content against a given XSD schema.

// Arrange
string xmlContent = XmlTestData.GetValidXmlContent();
string xsdContent = XmlTestData.GetXsdMarkup();

IXsdValidator xsdValidator = new XsdValidator();

// Act
var validationResult = xsdValidator.Validate(xmlContent, xsdContent);

// Assert
validationResult.IsValid.Should().BeTrue();
Using object extension methods

There is a number of extension methods for type System.Object in ObjectExtensions. You can simply call SerializeToXml resp. DeserializeFromXml on any .NET object. Following unit test gives an example:

// Arrange
float inputValue = 123.456f;

// Act
var serializedString = inputValue.SerializeToXml();

// Assert
serializedString.Should().NotBeNullOrEmpty();
Dependency management

If you do not use an IoC framework, you can call XmlSerializerHelper.Current to get a singleton instance of IXmlSerializerHelper.

string serializedString = XmlSerializerHelper.Current.SerializeToXml(value: new object(), preserveTypeInformation: false);

The same applies to XsdValidator.Current. However, it is advised to register the mentioned interfaces along with their respective implementations in an IoC framework.

License

This project is Copyright © 2026 Thomas Galliker.

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 is compatible.  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 is compatible. 
.NET Framework 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.
  • .NETStandard 2.0

    • No dependencies.
  • .NETStandard 2.1

    • No dependencies.
  • net8.0

    • No dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
5.0.9 0 7/30/2026
5.0.7-pre 87 7/24/2026
5.0.6-pre 85 7/24/2026
5.0.4-pre 90 7/24/2026
5.0.2-pre 103 7/24/2026
4.0.19096.1 91,170 4/6/2019
4.0.19095.5-pre 781 4/5/2019
4.0.19095.3-pre 761 4/5/2019
3.0.3 34,297 8/7/2018
3.0.3-pre1 1,200 8/3/2018
3.0.2 1,403 8/2/2018
3.0.2-pre2 3,557 8/10/2017
3.0.2-pre1 1,236 8/10/2017
3.0.1 3,665 6/8/2017
3.0.1-pre3 1,357 10/20/2016
3.0.1-pre2 1,305 10/20/2016
3.0.1-pre1 1,327 10/20/2016
3.0.0 5,159 5/9/2016
3.0.0-pre12 1,371 5/6/2016
3.0.0-pre11 1,320 5/6/2016
Loading failed

5.0
- Modernized to netstandard2.0, netstandard2.1 and net8.0 (dropped netstandard1.0 and net45)
- Migrated CI to azure-pipelines.yml; solution to slnx

4.0
- Refactor to support .NET Standard 2.0

3.0.3
- Add support for .Net Standard
- Last release with PCL support

3.0.2
- Add serialization support for Nullable types
- Remove Windows Phone support

3.0.1
- New feature: SerializeToXmlDocument (.Net Platform only)

3.0.0
- Add XsdValidator to support XSD schema validation. (Currently only supported on .Net 4.5, Xamarin.iOS, Xamarin.Android)

2.0.3
- Add text encoding parameter

2.0.2
- Refactored to provide non-static implementation of XmlSerializerHelper
- New IXmlSerializerHelper interface as abstraction for XmlSerializerHelper
- Static access to IXmlSerializerHelper via XmlSerializerHelper.Current

1.0.1
- Initial release