Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All

IXmlSerializable.ReadXml Method

Generates an object from its XML representation.

Namespace:  System.Xml.Serialization
Assemblies:   System.Xml.XmlSerializer (in System.Xml.XmlSerializer.dll)
  System.Xml (in System.Xml.dll)
  System.Xml.ReaderWriter (in System.Xml.ReaderWriter.dll)

'Declaration
Sub ReadXml ( _
	reader As XmlReader _
)

Parameters

reader
Type: System.Xml.XmlReader

The XmlReader stream from which the object is deserialized.

The ReadXml method must reconstitute your object using the information that was written by the WriteXml method.

When this method is called, the reader is positioned on the start tag that wraps the information for your type. That is, directly on the start tag that indicates the beginning of a serialized object. When this method returns, it must have read the entire element from beginning to end, including all of its contents. Unlike the WriteXml method, the framework does not handle the wrapper element automatically. Your implementation must do so. Failing to observe these positioning rules may cause code to generate unexpected runtime exceptions or corrupt data.

When implementing this method, you should consider the possibility that a malicious user might provide a well-formed but invalid XML representation in order to disable or otherwise alter the behavior of your application.

The following example illustrates an implementation of the ReadXml method.

No code example is currently available or this language may not be supported.

The following example illustrates the use of the XmlSerializer class to deserialize this object.

No code example is currently available or this language may not be supported.

.NET Framework

Supported in: 4.6, 4.5, 4, 3.5, 3.0, 2.0, 1.1

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

XNA Framework

Supported in: 3.0, 2.0, 1.0

.NET for Windows Phone apps

Supported in: Windows Phone 8.1, Windows Phone Silverlight 8.1, Windows Phone Silverlight 8

Portable Class Library

Supported in: Portable Class Library
Show:
© 2015 Microsoft