Edit

Share via


XDocument.LoadAsync Method

Definition

Overloads

LoadAsync(TextReader, LoadOptions, CancellationToken)

Creates a new XDocument and initializes its underlying XML tree using the specified TextReader parameter, optionally preserving white space.

LoadAsync(XmlReader, LoadOptions, CancellationToken)

Creates a new XDocument containing the contents of the specified XmlReader.

LoadAsync(Stream, LoadOptions, CancellationToken)

Asynchronously creates a new XDocument and initializes its underlying XML tree from the specified stream, optionally preserving white space.

LoadAsync(TextReader, LoadOptions, CancellationToken)

Source:
XDocument.cs
Source:
XDocument.cs
Source:
XDocument.cs

Creates a new XDocument and initializes its underlying XML tree using the specified TextReader parameter, optionally preserving white space.

public:
 static System::Threading::Tasks::Task<System::Xml::Linq::XDocument ^> ^ LoadAsync(System::IO::TextReader ^ textReader, System::Xml::Linq::LoadOptions options, System::Threading::CancellationToken cancellationToken);
public static System.Threading.Tasks.Task<System.Xml.Linq.XDocument> LoadAsync (System.IO.TextReader textReader, System.Xml.Linq.LoadOptions options, System.Threading.CancellationToken cancellationToken);
static member LoadAsync : System.IO.TextReader * System.Xml.Linq.LoadOptions * System.Threading.CancellationToken -> System.Threading.Tasks.Task<System.Xml.Linq.XDocument>
Public Shared Function LoadAsync (textReader As TextReader, options As LoadOptions, cancellationToken As CancellationToken) As Task(Of XDocument)

Parameters

textReader
TextReader

A reader that contains the raw XML to read into the newly created XDocument.

options
LoadOptions

A set of load options.

cancellationToken
CancellationToken

A cancellation token.

Returns

A new XDocument containing the contents of the specified TextReader.

Exceptions

The cancellation token was canceled. This exception is stored into the returned task.

Remarks

If LoadOptions.PreserveWhitespace is set, the XmlReaderSettings.IgnoreWhitespace property is set to false.

This method stores in the task it returns all non-usage exceptions that the method's synchronous counterpart can throw. If an exception is stored into the returned task, that exception will be thrown when the task is awaited. Usage exceptions, such as ArgumentException, are still thrown synchronously. For the stored exceptions, see the exceptions thrown by Load(TextReader, LoadOptions).

Applies to

LoadAsync(XmlReader, LoadOptions, CancellationToken)

Source:
XDocument.cs
Source:
XDocument.cs
Source:
XDocument.cs

Creates a new XDocument containing the contents of the specified XmlReader.

public:
 static System::Threading::Tasks::Task<System::Xml::Linq::XDocument ^> ^ LoadAsync(System::Xml::XmlReader ^ reader, System::Xml::Linq::LoadOptions options, System::Threading::CancellationToken cancellationToken);
public static System.Threading.Tasks.Task<System.Xml.Linq.XDocument> LoadAsync (System.Xml.XmlReader reader, System.Xml.Linq.LoadOptions options, System.Threading.CancellationToken cancellationToken);
static member LoadAsync : System.Xml.XmlReader * System.Xml.Linq.LoadOptions * System.Threading.CancellationToken -> System.Threading.Tasks.Task<System.Xml.Linq.XDocument>
Public Shared Function LoadAsync (reader As XmlReader, options As LoadOptions, cancellationToken As CancellationToken) As Task(Of XDocument)

Parameters

reader
XmlReader

A reader containing the XML to be read into the new XDocument.

options
LoadOptions

A set of load options.

cancellationToken
CancellationToken

A cancellation token.

Returns

A new XDocument containing the contents of the specified XmlReader.

Exceptions

The cancellation token was canceled. This exception is stored into the returned task.

Remarks

This method stores in the task it returns all non-usage exceptions that the method's synchronous counterpart can throw. If an exception is stored into the returned task, that exception will be thrown when the task is awaited. Usage exceptions, such as ArgumentException, are still thrown synchronously. For the stored exceptions, see the exceptions thrown by Load(XmlReader, LoadOptions).

Applies to

LoadAsync(Stream, LoadOptions, CancellationToken)

Source:
XDocument.cs
Source:
XDocument.cs
Source:
XDocument.cs

Asynchronously creates a new XDocument and initializes its underlying XML tree from the specified stream, optionally preserving white space.

public:
 static System::Threading::Tasks::Task<System::Xml::Linq::XDocument ^> ^ LoadAsync(System::IO::Stream ^ stream, System::Xml::Linq::LoadOptions options, System::Threading::CancellationToken cancellationToken);
public static System.Threading.Tasks.Task<System.Xml.Linq.XDocument> LoadAsync (System.IO.Stream stream, System.Xml.Linq.LoadOptions options, System.Threading.CancellationToken cancellationToken);
static member LoadAsync : System.IO.Stream * System.Xml.Linq.LoadOptions * System.Threading.CancellationToken -> System.Threading.Tasks.Task<System.Xml.Linq.XDocument>
Public Shared Function LoadAsync (stream As Stream, options As LoadOptions, cancellationToken As CancellationToken) As Task(Of XDocument)

Parameters

stream
Stream

A stream containing the raw XML to read into the newly created XDocument.

options
LoadOptions

A set of load options.

cancellationToken
CancellationToken

A cancellation token.

Returns

A new XDocument containing the contents of the specified Stream.

Exceptions

The cancellation token was canceled. This exception is stored into the returned task.

Remarks

If LoadOptions.PreserveWhitespace is set, the underlying XmlReaderSettings.IgnoreWhitespace property is set to false.

This method stores in the task it returns all non-usage exceptions that the method's synchronous counterpart can throw. If an exception is stored into the returned task, that exception will be thrown when the task is awaited. Usage exceptions, such as ArgumentException, are still thrown synchronously. For the stored exceptions, see the exceptions thrown by Load(Stream, LoadOptions).

Applies to