System.Xml.Serialization.IXmlSerializable.ReadXml Method

Generates an object from its XML representation.

Syntax

public void ReadXml (System.Xml.XmlReader reader)

Parameters

reader
The System.Xml.XmlReader stream from which the object is deserialized.

Remarks

The IXmlSerializable.ReadXml(System.Xml.XmlReader) method must reconstitute your object using the information that was written by the IXmlSerializable.WriteXml(System.Xml.XmlWriter) 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 IXmlSerializable.WriteXml(System.Xml.XmlWriter) 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.

Requirements

Namespace: System.Xml.Serialization
Assembly: System.Xml (in System.Xml.dll)
Assembly Versions: 1.0.5000.0, 2.0.0.0, 4.0.0.0