XmlDocumentParser Class
Parses XML documents (https://html.spec.whatwg.org/multipage/xhtml.html#parsing-xhtml-documents). External entities are never loaded; the XHTML DOCTYPEs declare the HTML named character references.
public static class XmlDocumentParserMethods
| Name | Description |
|---|---|
| ParseDocument(Stream, XmlParserOptions?) | Parses XML from the current position of a stream, determining its encoding as for byte inputs. Buffers the input and leaves the caller-owned stream open. |
| ParseDocument(ReadOnlySpan<byte>, XmlParserOptions?) | Parses XML bytes, determining the encoding from the byte order mark, byte signature and XML declaration, or UTF-8 by default. Throws XmlException for malformed bytes, conflicting encodings or invalid XML. |
| ParseDocument(string, XmlParserOptions?) | Parses an XML document. Throws XmlException when the document is not namespace-well-formed. The document has no browsing context: use BrowsingContext.Navigate to load a document in a browsing context. |
| ParseDocumentAsync(Stream, XmlParserOptions?, CancellationToken) | Asynchronously reads XML from the current position of a stream and waits until the parser has finished. Buffers the input and leaves the caller-owned stream open. Cancellation interrupts reading and waiting for the parser. |
| ParseDocumentAsync(string, XmlParserOptions?, CancellationToken) | Parses an XML 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. Throws XmlException when the document is not namespace-well-formed (before the parser waits for a script; afterwards, the document shows the error). |
ParseDocument overloads
ParseDocument(Stream, XmlParserOptions?)
XmlDocumentParser.csParses XML from the current position of a stream, determining its encoding as for byte inputs. Buffers the input and leaves the caller-owned stream open.
public static Document ParseDocument(Stream stream, XmlParserOptions? options = null)ParseDocument(ReadOnlySpan<byte>, XmlParserOptions?)
XmlDocumentParser.csParses XML bytes, determining the encoding from the byte order mark, byte signature and XML declaration, or UTF-8 by default. Throws XmlException for malformed bytes, conflicting encodings or invalid XML.
public static Document ParseDocument(ReadOnlySpan<byte> xml, XmlParserOptions? options = null)ParseDocument(string, XmlParserOptions?)
XmlDocumentParser.csParses an XML document. Throws XmlException when the document is not namespace-well-formed. The document has no browsing context: use BrowsingContext.Navigate to load a document in a browsing context.
public static Document ParseDocument(string xml, XmlParserOptions? options = null)ParseDocumentAsync overloads
ParseDocumentAsync(Stream, XmlParserOptions?, CancellationToken)
XmlDocumentParser.csAsynchronously reads XML from the current position of a stream and waits until the parser has finished. Buffers the input and leaves the caller-owned stream open. Cancellation interrupts reading and waiting for the parser.
net10.0
public static Task<Document> ParseDocumentAsync(Stream stream, XmlParserOptions? options = null, CancellationToken cancellationToken = default)net11.0
public static Task<Document> ParseDocumentAsync(Stream stream, XmlParserOptions? options = null, CancellationToken cancellationToken = default)ParseDocumentAsync(string, XmlParserOptions?, CancellationToken)
XmlDocumentParser.csParses an XML 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. Throws XmlException when the document is not namespace-well-formed (before the parser waits for a script; afterwards, the document shows the error).
net10.0
public static Task<Document> ParseDocumentAsync(string xml, XmlParserOptions? options = null, CancellationToken cancellationToken = default)net11.0
public static Task<Document> ParseDocumentAsync(string xml, XmlParserOptions? options = null, CancellationToken cancellationToken = default)