Represents a reader that provides fast, non-cached, forward-only access to XML data.
For a list of all members of this type, see XmlTextReader Members.
[Visual Basic] Public Class XmlTextReader Inherits XmlReader Implements IXmlLineInfo [C#] public class XmlTextReader : XmlReader, IXmlLineInfo [C++] public __gc class XmlTextReader : public XmlReader, IXmlLineInfo [JScript] public class XmlTextReader extends XmlReader implements IXmlLineInfo
Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
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 XmlReader and conforms to the W3C Extensible Markup Language (XML) 1.0 and the Namespaces in XML recommendations. XmlTextReader provides the following functionality:
- Enforces the rules of well-formed XML.
- XmlTextReader does not provide data validation.
- Checks that DocumentType nodes are well-formed. XmlTextReader checks the DTD for well-formedness, but does not validate using the DTD.
- For nodes whose NodeType is XmlNodeType.EntityReference, a single empty EntityReference node is returned (that is, the Value property is String.Empty). 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.
- Does not expand default attributes.
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 XmlValidatingReader.
To read strongly typed data, use the XmlConvert class. For example, the following C# code reads in data and converts it from a String to a Double.
Double price = XmlConvert.ToDouble(reader.Value);
XmlTextReader throws an 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.
Notes to Inheritors: This class has an inheritance demand. Full trust is required to inherit from XmlTextReader. See Inheritance Demands for more information.
For further discussion on the XmlReader classes, see Reading XML with the XmlReader.
Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family, .NET Compact Framework
Assembly: System.Xml (in System.Xml.dll)