XmlObjectSerializer.ReadObject Method

Definition

Reads an XML document or document stream and returns the deserialized object.

Overloads

ReadObject(Stream)

Reads the XML stream or document with a Stream and returns the deserialized object.

ReadObject(XmlDictionaryReader)

Reads the XML document or stream with an XmlDictionaryReader and returns the deserialized object.

ReadObject(XmlReader)

Reads the XML document or stream with an XmlReader and returns the deserialized object.

ReadObject(XmlDictionaryReader, Boolean)

Reads the XML stream or document with an XmlDictionaryReader and returns the deserialized object; it also enables you to specify whether the serializer can read the data before attempting to read it.

ReadObject(XmlReader, Boolean)

Reads the XML document or stream with an XmlReader and returns the deserialized object; it also enables you to specify whether the serializer can read the data before attempting to read it.

ReadObject(Stream)

Source:
XmlObjectSerializer.cs
Source:
XmlObjectSerializer.cs
Source:
XmlObjectSerializer.cs

Reads the XML stream or document with a Stream and returns the deserialized object.

public virtual object ReadObject (System.IO.Stream stream);
public virtual object? ReadObject (System.IO.Stream stream);

Parameters

stream
Stream

A Stream used to read the XML stream or document.

Returns

The deserialized object.

Remarks

This method is a virtual method, and has a default implementation that creates a dictionary reader to read the underlying stream and deserialize it. The default implementation assumes the stream is text or XML.

Applies to

.NET 9 and other versions
Product Versions
.NET Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9
.NET Framework 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0, 2.1
UWP 10.0

ReadObject(XmlDictionaryReader)

Source:
XmlObjectSerializer.cs
Source:
XmlObjectSerializer.cs
Source:
XmlObjectSerializer.cs

Reads the XML document or stream with an XmlDictionaryReader and returns the deserialized object.

public virtual object ReadObject (System.Xml.XmlDictionaryReader reader);
public virtual object? ReadObject (System.Xml.XmlDictionaryReader reader);

Parameters

reader
XmlDictionaryReader

An XmlDictionaryReader used to read the XML document.

Returns

The deserialized object.

Remarks

This method is a virtual method, and has a default implementation that creates a dictionary reader to read the underlying stream and deserialize it. The default implementation assumes the stream is text or XML.

Applies to

.NET 9 and other versions
Product Versions
.NET Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9
.NET Framework 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0, 2.1
UWP 10.0

ReadObject(XmlReader)

Source:
XmlObjectSerializer.cs
Source:
XmlObjectSerializer.cs
Source:
XmlObjectSerializer.cs

Reads the XML document or stream with an XmlReader and returns the deserialized object.

public virtual object ReadObject (System.Xml.XmlReader reader);
public virtual object? ReadObject (System.Xml.XmlReader reader);

Parameters

reader
XmlReader

An XmlReader used to read the XML stream or document.

Returns

The deserialized object.

Applies to

.NET 9 and other versions
Product Versions
.NET Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9
.NET Framework 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0, 2.1
UWP 10.0

ReadObject(XmlDictionaryReader, Boolean)

Source:
XmlObjectSerializer.cs
Source:
XmlObjectSerializer.cs
Source:
XmlObjectSerializer.cs

Reads the XML stream or document with an XmlDictionaryReader and returns the deserialized object; it also enables you to specify whether the serializer can read the data before attempting to read it.

public abstract object ReadObject (System.Xml.XmlDictionaryReader reader, bool verifyObjectName);
public abstract object? ReadObject (System.Xml.XmlDictionaryReader reader, bool verifyObjectName);

Parameters

reader
XmlDictionaryReader

An XmlDictionaryReader used to read the XML document.

verifyObjectName
Boolean

true to check whether the enclosing XML element name and namespace correspond to the root name and root namespace; otherwise, false to skip the verification.

Returns

The deserialized object.

Remarks

The verifyObjectName parameter uses the same code as the IsStartObject method to determine whether the element is the start of the object.

Applies to

.NET 9 and other versions
Product Versions
.NET Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9
.NET Framework 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0, 2.1
UWP 10.0

ReadObject(XmlReader, Boolean)

Source:
XmlObjectSerializer.cs
Source:
XmlObjectSerializer.cs
Source:
XmlObjectSerializer.cs

Reads the XML document or stream with an XmlReader and returns the deserialized object; it also enables you to specify whether the serializer can read the data before attempting to read it.

public virtual object ReadObject (System.Xml.XmlReader reader, bool verifyObjectName);
public virtual object? ReadObject (System.Xml.XmlReader reader, bool verifyObjectName);

Parameters

reader
XmlReader

An XmlReader used to read the XML document or stream.

verifyObjectName
Boolean

true to check whether the enclosing XML element name and namespace correspond to the root name and root namespace; false to skip the verification.

Returns

The deserialized object.

Remarks

The verifyObjectName parameter uses the same code as the IsStartObject method to determine whether the element is the start of the object.

Applies to

.NET 9 and other versions
Product Versions
.NET Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9
.NET Framework 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0, 2.1
UWP 10.0