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 https://www.nuget.org/packages/Microsoft.Xml.SgmlReader/ 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
};
doc.Load(sgmlReader);
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 (3)

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

Package Downloads
Restless.OfxSharper

Provides Ofx parsing and building services

Cube.Net.Rss

RSS library for CubeSoft libraries and applications.

SgmlSanitizer

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/xamarin-android
Xamarin.Android provides open-source bindings of the Android SDK for use with .NET managed languages such as C#
microsoft/XmlNotepad
XML Notepad provides a simple intuitive User Interface for browsing and editing XML documents.
xamarin/java.interop
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 211 9/29/2021
1.8.24 1,153 7/23/2021
1.8.23 244 7/21/2021
1.8.22 86 7/20/2021
1.8.21 3,276 3/18/2021
1.8.20 257 2/2/2021
1.8.19 677 1/29/2021
1.8.18 3,396 10/25/2020
1.8.17 2,100 7/24/2020
1.8.16 24,431 6/1/2020
1.8.15 259 6/1/2020
1.8.14 120,621 2/3/2017
1.8.13 1,154 9/11/2016
1.8.12 672 9/11/2016