HtmlParserOptions Class

Options of the HtmlDocumentParser.

public sealed class HtmlParserOptions

Constructors

NameDescription
HtmlParserOptions()

HtmlParserOptions()

HtmlDocumentParser.cs
public HtmlParserOptions()

No documentation is available.

Properties

NameDescription
AllowDeclarativeShadowRootsGets or sets whether <template shadowrootmode> creates declarative shadow roots. The default is true.
CustomElementRegistryGets or sets the custom element registry of the parsed document, which defines the custom elements the parser creates (see CustomElementRegistry). The default is null: the document has no registry, and custom elements are not defined. The documents loaded in a browsing context (see BrowsingContext.Navigate) get the global registry of their window instead.
DefaultEncodingGets or sets the encoding used when it cannot be determined from the content. The default is windows-1252.
EncodingDetectorGets or sets the detector of the encoding of the documents parsed from bytes that do not declare their encoding: no byte order mark, no HtmlParserOptions.TransportEncoding, no meta element, and no container document that gives its encoding. The default is EncodingDetector.Default, which guesses the legacy encodings from the content (and UTF-8 when HtmlParserOptions.Url is not set or is a file: URL). Null disables the detection: these documents get the HtmlParserOptions.DefaultEncoding, as the ones whose encoding is not detected. The detector is not used when the HtmlParserOptions.DefaultEncoding is UTF-16BE/LE (the detected encodings are ASCII-compatible).
ParseErrorHandlerGets or sets the callback invoked for each parse error. Tracking positions has no cost when this is null.
ScriptingEnabledGets or sets whether scripting is enabled for the parsed documents: this changes how <noscript> is parsed. The default is false (as for documents created by DOMParser). The scripts never run in the parsed documents: they only run in the documents loaded by BrowsingContext.Navigate in a browsing context that has a BrowsingContextOptions.ScriptEngine.
TransportEncodingGets or sets the encoding label provided by the transport layer (e.g. the charset of the Content-Type header).
UrlGets or sets the URL of the document (used to resolve relative URLs). The default is about:blank.

AllowDeclarativeShadowRoots

HtmlDocumentParser.cs

Gets or sets whether <template shadowrootmode> creates declarative shadow roots. The default is true.

public bool AllowDeclarativeShadowRoots { get; init; }

Property value

bool

CustomElementRegistry

HtmlDocumentParser.cs

Gets or sets the custom element registry of the parsed document, which defines the custom elements the parser creates (see CustomElementRegistry). The default is null: the document has no registry, and custom elements are not defined. The documents loaded in a browsing context (see BrowsingContext.Navigate) get the global registry of their window instead.

public CustomElementRegistry? CustomElementRegistry { get; init; }

DefaultEncoding

HtmlDocumentParser.cs

Gets or sets the encoding used when it cannot be determined from the content. The default is windows-1252.

public string DefaultEncoding { get; init; }

Property value

string

EncodingDetector

HtmlDocumentParser.cs

Gets or sets the detector of the encoding of the documents parsed from bytes that do not declare their encoding: no byte order mark, no HtmlParserOptions.TransportEncoding, no meta element, and no container document that gives its encoding. The default is EncodingDetector.Default, which guesses the legacy encodings from the content (and UTF-8 when HtmlParserOptions.Url is not set or is a file: URL). Null disables the detection: these documents get the HtmlParserOptions.DefaultEncoding, as the ones whose encoding is not detected. The detector is not used when the HtmlParserOptions.DefaultEncoding is UTF-16BE/LE (the detected encodings are ASCII-compatible).

public EncodingDetector? EncodingDetector { get; init; }

Property value

EncodingDetector?

ParseErrorHandler

HtmlDocumentParser.cs

Gets or sets the callback invoked for each parse error. Tracking positions has no cost when this is null.

public Action<HtmlParseError>? ParseErrorHandler { get; init; }

ScriptingEnabled

HtmlDocumentParser.cs

Gets or sets whether scripting is enabled for the parsed documents: this changes how <noscript> is parsed. The default is false (as for documents created by DOMParser). The scripts never run in the parsed documents: they only run in the documents loaded by BrowsingContext.Navigate in a browsing context that has a BrowsingContextOptions.ScriptEngine.

public bool ScriptingEnabled { get; init; }

Property value

bool

TransportEncoding

HtmlDocumentParser.cs

Gets or sets the encoding label provided by the transport layer (e.g. the charset of the Content-Type header).

public string? TransportEncoding { get; init; }

Property value

string?

Gets or sets the URL of the document (used to resolve relative URLs). The default is about:blank.

public string? Url { get; init; }

Property value

string?