HtmlDocumentParser Class
Parses HTML documents and fragments according to the HTML Standard.
public sealed class HtmlDocumentParserConstructors
| Name | Description |
|---|---|
| HtmlDocumentParser(HtmlParserOptions?) | Creates a parser with the given options, or with the default options when options is null. |
HtmlDocumentParser(HtmlParserOptions?)
HtmlDocumentParser.csCreates a parser with the given options, or with the default options when options is null.
public HtmlDocumentParser(HtmlParserOptions? options = null)Parameters
optionsHtmlParserOptions?
Methods
| Name | Description |
|---|---|
| Parse(Stream) | Parses an HTML document from a stream, determining the character encoding as specified. |
| Parse(ReadOnlySpan<byte>) | Parses an HTML document from bytes, determining the character encoding as specified. |
| Parse(string) | Parses an HTML document from a string (the encoding is irrelevant). |
| ParseAsync(Stream, CancellationToken) | Parses an HTML document from a stream, determining the character encoding as specified, and waits until the parser has finished (see HtmlDocumentParser.ParseAsync). |
| ParseAsync(string, CancellationToken) | Parses an HTML document from a string, and waits until the parser has finished: while the parser waits for a script, the tasks of the DomEventLoop of the browsing context run. |
| ParseDocument(string, HtmlParserOptions?) | Parses an HTML document. The document has no browsing context: use BrowsingContext.Navigate to load a document in a browsing context. |
| ParseDocumentAsync(string, HtmlParserOptions?, CancellationToken) | Parses an HTML document, and waits until the parser has finished: while the parser waits for a script, the tasks of the DomEventLoop of the browsing context run. |
| ParseFragment(string, Element) | Runs the HTML fragment parsing algorithm (https://html.spec.whatwg.org/multipage/parsing.html#html-fragment-parsing-algorithm) with context as the context element. The nodes are created in the context's node document. |
Parse overloads
Parse(Stream)
HtmlDocumentParser.csParse(ReadOnlySpan<byte>)
HtmlDocumentParser.csParses an HTML document from bytes, determining the character encoding as specified.
public Document Parse(ReadOnlySpan<byte> bytes)Parse(string)
HtmlDocumentParser.csParseAsync overloads
ParseAsync(Stream, CancellationToken)
HtmlDocumentParser.csParses an HTML document from a stream, determining the character encoding as specified, and waits until the parser has finished (see HtmlDocumentParser.ParseAsync).
net10.0
public Task<Document> ParseAsync(Stream stream, CancellationToken cancellationToken = default)net11.0
public Task<Document> ParseAsync(Stream stream, CancellationToken cancellationToken = default)ParseAsync(string, CancellationToken)
HtmlDocumentParser.csParses an HTML document from a string, and waits until the parser has finished: while the parser waits for a script, the tasks of the DomEventLoop of the browsing context run.
net10.0
public Task<Document> ParseAsync(string html, CancellationToken cancellationToken = default)net11.0
public Task<Document> ParseAsync(string html, CancellationToken cancellationToken = default)ParseDocument(string, HtmlParserOptions?)
HtmlDocumentParser.csParses an HTML document. The document has no browsing context: use BrowsingContext.Navigate to load a document in a browsing context.
public static Document ParseDocument(string html, HtmlParserOptions? options = null)ParseDocumentAsync(string, HtmlParserOptions?, CancellationToken)
HtmlDocumentParser.csParses an HTML document, and waits until the parser has finished: while the parser waits for a script, the tasks of the DomEventLoop of the browsing context run.
public static Task<Document> ParseDocumentAsync(string html, HtmlParserOptions? options = null, CancellationToken cancellationToken = default)ParseFragment(string, Element)
HtmlDocumentParser.csRuns the HTML fragment parsing algorithm (https://html.spec.whatwg.org/multipage/parsing.html#html-fragment-parsing-algorithm) with context as the context element. The nodes are created in the context's node document.
public DocumentFragment ParseFragment(string html, Element context)