Microsoft.Xml.SgmlReader 1.8.25

Install-Package Microsoft.Xml.SgmlReader -Version 1.8.25
dotnet add package Microsoft.Xml.SgmlReader --version 1.8.25
<PackageReference Include="Microsoft.Xml.SgmlReader" Version="1.8.25" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Microsoft.Xml.SgmlReader --version 1.8.25
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Microsoft.Xml.SgmlReader, 1.8.25"
#r directive can be used in F# Interactive, C# scripting and .NET Interactive. Copy this into the interactive tool or source code of the script to reference the package.
// Install Microsoft.Xml.SgmlReader as a Cake Addin
#addin nuget:?package=Microsoft.Xml.SgmlReader&version=1.8.25

// Install Microsoft.Xml.SgmlReader as a Cake Tool
#tool nuget:?package=Microsoft.Xml.SgmlReader&version=1.8.25
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

SgmlReader - Convert (almost) any HTML to valid XML

SgmlReader is a versatile C# .NET library written by Chris Lovett for parsing SGML files using the XmlReader API including HTML and OFX data. A command line utility is also provided which outputs the well formed XML result.

MindTouch uses the SgmlReader library extensively. They have also made many improvements to it.

SgmlReaderDll API

The SgmlReader is an implementation of the XmlReader API. So the only thing you really need to know is how to construct it. SgmlReader has a default constructor, then you need to set some of the properties. To load a DTD you must specify DocType="HTML" or you must provide a SystemLiteral. To specify the SGML document you must provide either the InputStream or Href. Everything else is optional. Then you can read from this reader like any other XmlReader class.

Nuget Package

This code is packaged and published at for your convenience. Using Visual Studio, Manage Nuget Packages simply search for the online package named "Microsoft.Xml.SgmlReader" add it to your project and you are good to go.

Sample Usage

// setup SgmlReader
Sgml.SgmlReader sgmlReader = new Sgml.SgmlReader()
    DocType = "HTML",
    WhitespaceHandling = WhitespaceHandling.All,
    CaseFolding = Sgml.CaseFolding.ToLower,
    InputStream = reader

// create document
XmlDocument doc = new XmlDocument()
    PreserveWhitespace = true,
    XmlResolver = null
return doc;

Release History

Release notes for 1.8.25

  • Performance improvement parsing attributes with empty values.
  • .NETCoreApp 3.1

    • No dependencies.
  • .NETFramework 4.5

    • No dependencies.
  • .NETFramework 4.6

    • No dependencies.
  • .NETFramework 4.7

    • No dependencies.
  • .NETFramework 4.8

    • No dependencies.
  • .NETStandard 2.0

    • No dependencies.
  • .NETStandard 2.1

    • No dependencies.
  • net5.0

    • No dependencies.
  • UAP 0.0

    • No dependencies.

NuGet packages (4)

Showing the top 4 NuGet packages that depend on Microsoft.Xml.SgmlReader:

Package Downloads

Provides Ofx parsing and building services


OFX file parser in a .NET Standard library


RSS library for CubeSoft libraries and applications.


A sanitizer to remove elements and attributes from SGML based text files, such as HTML and XML. Note that this is a very simple implementation, but by using whitelists and a naïve URL detection implementation XSS may be prevented. Use at your own risk though.

GitHub repositories (3)

Showing the top 3 popular GitHub repositories that depend on Microsoft.Xml.SgmlReader:

Repository Stars
Xamarin.Android provides open-source bindings of the Android SDK for use with .NET managed languages such as C#
XML Notepad provides a simple intuitive User Interface for browsing and editing XML documents.
Java.Interop provides open-source bindings of Java's Java Native Interface (JNI) for use with .NET managed languages such as C#
Version Downloads Last updated
1.8.25 1,982 9/29/2021
1.8.24 1,899 7/23/2021
1.8.23 286 7/21/2021
1.8.22 125 7/20/2021
1.8.21 4,593 3/18/2021
1.8.20 292 2/2/2021
1.8.19 709 1/29/2021
1.8.18 3,831 10/25/2020
1.8.17 2,340 7/24/2020
1.8.16 24,476 6/1/2020
1.8.15 298 6/1/2020
1.8.14 134,901 2/3/2017
1.8.13 1,198 9/11/2016
1.8.12 705 9/11/2016