System.Xml.XmlTextReader.ResetState Method

Resets the state of the reader to ReadState.Initial.

Syntax

public void ResetState ()

Exceptions

TypeReason
InvalidOperationExceptionThe current instance was constructed with a System.Xml.XmlParserContext.

Remarks

Note:

In the dnprdnext release, the recommended practice is to create System.Xml.XmlReader instances using the erload:System.Xml.XmlReader.Create method. This allows you to take full advantage of the new features introduced in this release. For more information, see Creating XML Readers.

This method enables you to parse multiple XML documents in a single stream. When you reach the end of an XML document, you can call ResetState to reset the state of the reader in preparation for the next XML document.

Note:

The documents in the stream must share the same encoding. If this is not the case, when ResetState is called an System.Xml.XmlException is thrown. (This is a change in behavior from .NET Framework version 1.1 and earlier).

The following properties are not affected by ResetState.

Requirements

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