Table of Contents

Class HtmlParser

Namespace
AngleSharp.Html.Parser
Assembly
AngleSharp.dll

Creates an instance of the HTML parser front-end.

public class HtmlParser : EventTarget, IHtmlParser, IParser, IEventTarget
Inheritance
HtmlParser
Implements
Inherited Members
Extension Methods

Constructors

HtmlParser()

Creates a new parser with the default options and context.

public HtmlParser()

HtmlParser(HtmlParserOptions)

Creates a new parser with the custom options.

public HtmlParser(HtmlParserOptions options)

Parameters

options HtmlParserOptions

The options to use.

HtmlParser(HtmlParserOptions, IBrowsingContext?)

Creates a new parser with the custom options and the given context.

public HtmlParser(HtmlParserOptions options, IBrowsingContext? context)

Parameters

options HtmlParserOptions

The options to use.

context IBrowsingContext

The context to use.

Properties

Options

Gets the specified options.

public HtmlParserOptions Options { get; }

Property Value

HtmlParserOptions

Methods

ParseDocument(Stream)

Parses the stream and returns the result.

public IHtmlDocument ParseDocument(Stream source)

Parameters

source Stream

Returns

IHtmlDocument

ParseDocument(string)

Parses the string and returns the result.

public IHtmlDocument ParseDocument(string source)

Parameters

source string

Returns

IHtmlDocument

ParseDocumentAsync(Stream, CancellationToken)

Parses the stream asynchronously with option to cancel.

public Task<IHtmlDocument> ParseDocumentAsync(Stream source, CancellationToken cancel)

Parameters

source Stream
cancel CancellationToken

Returns

Task<IHtmlDocument>

ParseDocumentAsync(string, CancellationToken)

Parses the string asynchronously with option to cancel.

public Task<IHtmlDocument> ParseDocumentAsync(string source, CancellationToken cancel)

Parameters

source string
cancel CancellationToken

Returns

Task<IHtmlDocument>

ParseFragment(Stream, IElement)

Parses the stream and returns the result.

public INodeList ParseFragment(Stream source, IElement contextElement)

Parameters

source Stream
contextElement IElement

Returns

INodeList

ParseFragment(string, IElement)

Parses the string and returns the result.

public INodeList ParseFragment(string source, IElement contextElement)

Parameters

source string
contextElement IElement

Returns

INodeList

ParseHead(Stream)

Parses the stream and returns the head.

public IHtmlHeadElement? ParseHead(Stream source)

Parameters

source Stream

Returns

IHtmlHeadElement

ParseHead(string)

Parses the string and returns the head.

public IHtmlHeadElement? ParseHead(string source)

Parameters

source string

Returns

IHtmlHeadElement

ParseHeadAsync(Stream, CancellationToken)

Parses the stream asynchronously with option to cancel.

public Task<IHtmlHeadElement?> ParseHeadAsync(Stream source, CancellationToken cancel)

Parameters

source Stream
cancel CancellationToken

Returns

Task<IHtmlHeadElement>

ParseHeadAsync(string, CancellationToken)

Parses the string asynchronously with option to cancel.

public Task<IHtmlHeadElement?> ParseHeadAsync(string source, CancellationToken cancel)

Parameters

source string
cancel CancellationToken

Returns

Task<IHtmlHeadElement>

Events

Error

Fired when a HTML parse error is encountered.

public event DomEventHandler Error

Event Type

DomEventHandler

Parsed

Fired when the HTML parser is finished.

public event DomEventHandler Parsed

Event Type

DomEventHandler

Parsing

Fired when the HTML parser is starting.

public event DomEventHandler Parsing

Event Type

DomEventHandler