System.Xml.XmlTextReader Class

Represents a reader that provides fast, non-cached, forward-only access to XML data.

See Also: XmlTextReader Members

Syntax

public class XmlTextReader : XmlReader, Mono.Xml.IHasXmlParserContext, IXmlLineInfo, IXmlNamespaceResolver

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.

System.Xml.XmlTextReader provides forward-only, read-only access to a stream of XML data. The current node refers to the node on which the reader is positioned. The reader is advanced using any of the read methods and properties reflect the value of the current node.

This class implements System.Xml.XmlReader and conforms to the W3C Extensible Markup Language (XML) 1.0 and the Namespaces in XML recommendations. XmlTextReader provides the following functionality:

Note:

The actual declarations of entities in the DTD are called Entity nodes. When you refer to these nodes in your data, they are called EntityReference nodes.

Because the XmlTextReader does not perform the extra checks required for data validation, it provides a fast well-formedness parser.

To perform data validation, use a validating System.Xml.XmlReader. For more information, see Validating XML Data with XmlReader.

To read XML data from an System.Xml.XmlDocument, use System.Xml.XmlNodeReader.

XmlTextReader throws an System.Xml.XmlException on XML parse errors. After an exception is thrown the state of the reader is not predictable. For example, the reported node type may be different than the actual node type of the current node. Use the XmlTextReader.ReadState property to check whether a reader is in error state.

For further discussion on the XmlReader classes, see Reading XML with the XmlReader.

Security Considerations

The following are things to consider when using the System.Xml.XmlTextReader class.

Thread Safety

All public static members of this type are safe for multithreaded operations. No instance members are guaranteed to be thread safe.

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