XmlTextReader Class
TOC
Collapse the table of content
Expand the table of content

XmlTextReader Class

 

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

Starting with the .NET Framework 2.0, we recommend that you use the System.Xml.XmlReader class instead.

Namespace:   System.Xml
Assembly:  System.Xml (in System.Xml.dll)

System.Object
  System.Xml.XmlReader
    System.Xml.XmlTextReader

[PermissionSetAttribute(SecurityAction.InheritanceDemand, Name = "FullTrust")]
public class XmlTextReader : XmlReader, IXmlLineInfo, IXmlNamespaceResolver

NameDescription
System_CAPS_protmethodXmlTextReader()

Initializes a new instance of the XmlTextReader.

System_CAPS_pubmethodXmlTextReader(Stream)

Initializes a new instance of the XmlTextReader class with the specified stream.

System_CAPS_pubmethodXmlTextReader(Stream, XmlNameTable)

Initializes a new instance of the XmlTextReader class with the specified stream and XmlNameTable.

System_CAPS_pubmethodXmlTextReader(Stream, XmlNodeType, XmlParserContext)

Initializes a new instance of the XmlTextReader class with the specified stream, XmlNodeType, and XmlParserContext.

System_CAPS_pubmethodXmlTextReader(String)

Initializes a new instance of the XmlTextReader class with the specified file.

System_CAPS_pubmethodXmlTextReader(String, Stream)

Initializes a new instance of the XmlTextReader class with the specified URL and stream.

System_CAPS_pubmethodXmlTextReader(String, Stream, XmlNameTable)

Initializes a new instance of the XmlTextReader class with the specified URL, stream and XmlNameTable.

System_CAPS_pubmethodXmlTextReader(String, TextReader)

Initializes a new instance of the XmlTextReader class with the specified URL and TextReader.

System_CAPS_pubmethodXmlTextReader(String, TextReader, XmlNameTable)

Initializes a new instance of the XmlTextReader class with the specified URL, TextReader and XmlNameTable.

System_CAPS_pubmethodXmlTextReader(String, XmlNameTable)

Initializes a new instance of the XmlTextReader class with the specified file and XmlNameTable.

System_CAPS_pubmethodXmlTextReader(String, XmlNodeType, XmlParserContext)

Initializes a new instance of the XmlTextReader class with the specified string, XmlNodeType, and XmlParserContext.

System_CAPS_pubmethodXmlTextReader(TextReader)

Initializes a new instance of the XmlTextReader class with the specified TextReader.

System_CAPS_pubmethodXmlTextReader(TextReader, XmlNameTable)

Initializes a new instance of the XmlTextReader class with the specified TextReader and XmlNameTable.

System_CAPS_protmethodXmlTextReader(XmlNameTable)

This API supports the product infrastructure and is not intended to be used directly from your code. Initializes a new instance of the XmlTextReader class with the specified XmlNameTable.

NameDescription
System_CAPS_pubpropertyAttributeCount

Gets the number of attributes on the current node.(Overrides XmlReader.AttributeCount.)

System_CAPS_pubpropertyBaseURI

Gets the base URI of the current node.(Overrides XmlReader.BaseURI.)

System_CAPS_pubpropertyCanReadBinaryContent

Gets a value indicating whether the XmlTextReader implements the binary content read methods.(Overrides XmlReader.CanReadBinaryContent.)

System_CAPS_pubpropertyCanReadValueChunk

Gets a value indicating whether the XmlTextReader implements the ReadValueChunk method.(Overrides XmlReader.CanReadValueChunk.)

System_CAPS_pubpropertyCanResolveEntity

Gets a value indicating whether this reader can parse and resolve entities.(Overrides XmlReader.CanResolveEntity.)

System_CAPS_pubpropertyDepth

Gets the depth of the current node in the XML document.(Overrides XmlReader.Depth.)

System_CAPS_pubpropertyDtdProcessing

Gets or sets the DtdProcessing enumeration.

System_CAPS_pubpropertyEncoding

Gets the encoding of the document.

System_CAPS_pubpropertyEntityHandling

Gets or sets a value that specifies how the reader handles entities.

System_CAPS_pubpropertyEOF

Gets a value indicating whether the reader is positioned at the end of the stream.(Overrides XmlReader.EOF.)

System_CAPS_pubpropertyHasAttributes

Gets a value indicating whether the current node has any attributes.(Inherited from XmlReader.)

System_CAPS_pubpropertyHasValue

Gets a value indicating whether the current node can have a Value other than String.Empty.(Overrides XmlReader.HasValue.)

System_CAPS_pubpropertyIsDefault

Gets a value indicating whether the current node is an attribute that was generated from the default value defined in the DTD or schema.(Overrides XmlReader.IsDefault.)

System_CAPS_pubpropertyIsEmptyElement

Gets a value indicating whether the current node is an empty element (for example, <MyElement/>).(Overrides XmlReader.IsEmptyElement.)

System_CAPS_pubpropertyItem[Int32]

When overridden in a derived class, gets the value of the attribute with the specified index.(Inherited from XmlReader.)

System_CAPS_pubpropertyItem[String]

When overridden in a derived class, gets the value of the attribute with the specified Name.(Inherited from XmlReader.)

System_CAPS_pubpropertyItem[String, String]

When overridden in a derived class, gets the value of the attribute with the specified LocalName and NamespaceURI.(Inherited from XmlReader.)

System_CAPS_pubpropertyLineNumber

Gets the current line number.

System_CAPS_pubpropertyLinePosition

Gets the current line position.

System_CAPS_pubpropertyLocalName

Gets the local name of the current node.(Overrides XmlReader.LocalName.)

System_CAPS_pubpropertyName

Gets the qualified name of the current node.(Overrides XmlReader.Name.)

System_CAPS_pubpropertyNamespaces

Gets or sets a value indicating whether to do namespace support.

System_CAPS_pubpropertyNamespaceURI

Gets the namespace URI (as defined in the W3C Namespace specification) of the node on which the reader is positioned.(Overrides XmlReader.NamespaceURI.)

System_CAPS_pubpropertyNameTable

Gets the XmlNameTable associated with this implementation.(Overrides XmlReader.NameTable.)

System_CAPS_pubpropertyNodeType

Gets the type of the current node.(Overrides XmlReader.NodeType.)

System_CAPS_pubpropertyNormalization

Gets or sets a value indicating whether to normalize white space and attribute values.

System_CAPS_pubpropertyPrefix

Gets the namespace prefix associated with the current node.(Overrides XmlReader.Prefix.)

System_CAPS_pubpropertyProhibitDtd

Obsolete.Gets or sets a value indicating whether to allow DTD processing. This property is obsolete. Use DtdProcessing instead.

System_CAPS_pubpropertyQuoteChar

Gets the quotation mark character used to enclose the value of an attribute node.(Overrides XmlReader.QuoteChar.)

System_CAPS_pubpropertyReadState

Gets the state of the reader.(Overrides XmlReader.ReadState.)

System_CAPS_pubpropertySchemaInfo

Gets the schema information that has been assigned to the current node as a result of schema validation.(Inherited from XmlReader.)

System_CAPS_pubpropertySettings

Gets the XmlReaderSettings object used to create this XmlReader instance.(Inherited from XmlReader.)

System_CAPS_pubpropertyValue

Gets the text value of the current node.(Overrides XmlReader.Value.)

System_CAPS_pubpropertyValueType

Gets The Common Language Runtime (CLR) type for the current node.(Inherited from XmlReader.)

System_CAPS_pubpropertyWhitespaceHandling

Gets or sets a value that specifies how white space is handled.

System_CAPS_pubpropertyXmlLang

Gets the current xml:lang scope.(Overrides XmlReader.XmlLang.)

System_CAPS_pubpropertyXmlResolver

Sets the XmlResolver used for resolving DTD references.

System_CAPS_pubpropertyXmlSpace

Gets the current xml:space scope.(Overrides XmlReader.XmlSpace.)

NameDescription
System_CAPS_pubmethodClose()

Changes the ReadState to Closed.(Overrides XmlReader.Close().)

System_CAPS_pubmethodDispose()

Releases all resources used by the current instance of the XmlReader class.(Inherited from XmlReader.)

System_CAPS_protmethodDispose(Boolean)

Releases the unmanaged resources used by the XmlReader and optionally releases the managed resources.(Inherited from XmlReader.)

System_CAPS_pubmethodEquals(Object)

Determines whether the specified object is equal to the current object.(Inherited from Object.)

System_CAPS_protmethodFinalize()

Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.(Inherited from Object.)

System_CAPS_pubmethodGetAttribute(Int32)

Gets the value of the attribute with the specified index.(Overrides XmlReader.GetAttribute(Int32).)

System_CAPS_pubmethodGetAttribute(String)

Gets the value of the attribute with the specified name.(Overrides XmlReader.GetAttribute(String).)

System_CAPS_pubmethodGetAttribute(String, String)

Gets the value of the attribute with the specified local name and namespace URI.(Overrides XmlReader.GetAttribute(String, String).)

System_CAPS_pubmethodGetHashCode()

Serves as the default hash function. (Inherited from Object.)

System_CAPS_pubmethodGetNamespacesInScope(XmlNamespaceScope)

Gets a collection that contains all namespaces currently in-scope.

System_CAPS_pubmethodGetRemainder()

Gets the remainder of the buffered XML.

System_CAPS_pubmethodGetType()

Gets the Type of the current instance.(Inherited from Object.)

System_CAPS_pubmethodGetValueAsync()

Asynchronously gets the value of the current node.(Inherited from XmlReader.)

System_CAPS_pubmethodHasLineInfo()

Gets a value indicating whether the class can return line information.

System_CAPS_pubmethodIsStartElement()

Calls MoveToContent and tests if the current content node is a start tag or empty element tag.(Inherited from XmlReader.)

System_CAPS_pubmethodIsStartElement(String)

Calls MoveToContent and tests if the current content node is a start tag or empty element tag and if the Name property of the element found matches the given argument.(Inherited from XmlReader.)

System_CAPS_pubmethodIsStartElement(String, String)

Calls MoveToContent and tests if the current content node is a start tag or empty element tag and if the LocalName and NamespaceURI properties of the element found match the given strings.(Inherited from XmlReader.)

System_CAPS_pubmethodLookupNamespace(String)

Resolves a namespace prefix in the current element's scope.(Overrides XmlReader.LookupNamespace(String).)

System_CAPS_protmethodMemberwiseClone()

Creates a shallow copy of the current Object.(Inherited from Object.)

System_CAPS_pubmethodMoveToAttribute(Int32)

Moves to the attribute with the specified index.(Overrides XmlReader.MoveToAttribute(Int32).)

System_CAPS_pubmethodMoveToAttribute(String)

Moves to the attribute with the specified name.(Overrides XmlReader.MoveToAttribute(String).)

System_CAPS_pubmethodMoveToAttribute(String, String)

Moves to the attribute with the specified local name and namespace URI.(Overrides XmlReader.MoveToAttribute(String, String).)

System_CAPS_pubmethodMoveToContent()

Checks whether the current node is a content (non-white space text, CDATA, Element, EndElement, EntityReference, or EndEntity) node. If the node is not a content node, the reader skips ahead to the next content node or end of file. It skips over nodes of the following type: ProcessingInstruction, DocumentType, Comment, Whitespace, or SignificantWhitespace.(Inherited from XmlReader.)

System_CAPS_pubmethodMoveToContentAsync()

Asynchronously checks whether the current node is a content node. If the node is not a content node, the reader skips ahead to the next content node or end of file.(Inherited from XmlReader.)

System_CAPS_pubmethodMoveToElement()

Moves to the element that contains the current attribute node.(Overrides XmlReader.MoveToElement().)

System_CAPS_pubmethodMoveToFirstAttribute()

Moves to the first attribute.(Overrides XmlReader.MoveToFirstAttribute().)

System_CAPS_pubmethodMoveToNextAttribute()

Moves to the next attribute.(Overrides XmlReader.MoveToNextAttribute().)

System_CAPS_pubmethodRead()

Reads the next node from the stream.(Overrides XmlReader.Read().)

System_CAPS_pubmethodReadAsync()

Asynchronously reads the next node from the stream.(Inherited from XmlReader.)

System_CAPS_pubmethodReadAttributeValue()

Parses the attribute value into one or more Text, EntityReference, or EndEntity nodes.(Overrides XmlReader.ReadAttributeValue().)

System_CAPS_pubmethodReadBase64(Byte[], Int32, Int32)

Decodes Base64 and returns the decoded binary bytes.

System_CAPS_pubmethodReadBinHex(Byte[], Int32, Int32)

Decodes BinHex and returns the decoded binary bytes.

System_CAPS_pubmethodReadChars(Char[], Int32, Int32)

Reads the text contents of an element into a character buffer. This method is designed to read large streams of embedded text by calling it successively.

System_CAPS_pubmethodReadContentAs(Type, IXmlNamespaceResolver)

Reads the content as an object of the type specified.(Inherited from XmlReader.)

System_CAPS_pubmethodReadContentAsAsync(Type, IXmlNamespaceResolver)

Asynchronously reads the content as an object of the type specified.(Inherited from XmlReader.)

System_CAPS_pubmethodReadContentAsBase64(Byte[], Int32, Int32)

Reads the content and returns the Base64 decoded binary bytes.(Overrides XmlReader.ReadContentAsBase64(Byte[], Int32, Int32).)

System_CAPS_pubmethodReadContentAsBase64Async(Byte[], Int32, Int32)

Asynchronously reads the content and returns the Base64 decoded binary bytes.(Inherited from XmlReader.)

System_CAPS_pubmethodReadContentAsBinHex(Byte[], Int32, Int32)

Reads the content and returns the BinHex decoded binary bytes.(Overrides XmlReader.ReadContentAsBinHex(Byte[], Int32, Int32).)

System_CAPS_pubmethodReadContentAsBinHexAsync(Byte[], Int32, Int32)

Asynchronously reads the content and returns the BinHex decoded binary bytes.(Inherited from XmlReader.)

System_CAPS_pubmethodReadContentAsBoolean()

Reads the text content at the current position as a Boolean.(Inherited from XmlReader.)

System_CAPS_pubmethodReadContentAsDateTime()

Reads the text content at the current position as a DateTime object.(Inherited from XmlReader.)

System_CAPS_pubmethodReadContentAsDateTimeOffset()

Reads the text content at the current position as a DateTimeOffset object.(Inherited from XmlReader.)

System_CAPS_pubmethodReadContentAsDecimal()

Reads the text content at the current position as a Decimal object.(Inherited from XmlReader.)

System_CAPS_pubmethodReadContentAsDouble()

Reads the text content at the current position as a double-precision floating-point number.(Inherited from XmlReader.)

System_CAPS_pubmethodReadContentAsFloat()

Reads the text content at the current position as a single-precision floating point number.(Inherited from XmlReader.)

System_CAPS_pubmethodReadContentAsInt()

Reads the text content at the current position as a 32-bit signed integer.(Inherited from XmlReader.)

System_CAPS_pubmethodReadContentAsLong()

Reads the text content at the current position as a 64-bit signed integer.(Inherited from XmlReader.)

System_CAPS_pubmethodReadContentAsObject()

Reads the text content at the current position as an Object.(Inherited from XmlReader.)

System_CAPS_pubmethodReadContentAsObjectAsync()

Asynchronously reads the text content at the current position as an Object.(Inherited from XmlReader.)

System_CAPS_pubmethodReadContentAsString()

Reads the text content at the current position as a String object.(Inherited from XmlReader.)

System_CAPS_pubmethodReadContentAsStringAsync()

Asynchronously reads the text content at the current position as a String object.(Inherited from XmlReader.)

System_CAPS_pubmethodReadElementContentAs(Type, IXmlNamespaceResolver)

Reads the element content as the requested type.(Inherited from XmlReader.)

System_CAPS_pubmethodReadElementContentAs(Type, IXmlNamespaceResolver, String, String)

Checks that the specified local name and namespace URI matches that of the current element, then reads the element content as the requested type.(Inherited from XmlReader.)

System_CAPS_pubmethodReadElementContentAsAsync(Type, IXmlNamespaceResolver)

Asynchronously reads the element content as the requested type.(Inherited from XmlReader.)

System_CAPS_pubmethodReadElementContentAsBase64(Byte[], Int32, Int32)

Reads the element and decodes the Base64 content.(Overrides XmlReader.ReadElementContentAsBase64(Byte[], Int32, Int32).)

System_CAPS_pubmethodReadElementContentAsBase64Async(Byte[], Int32, Int32)

Asynchronously reads the element and decodes theBase64 content.(Inherited from XmlReader.)

System_CAPS_pubmethodReadElementContentAsBinHex(Byte[], Int32, Int32)

Reads the element and decodes the BinHex content.(Overrides XmlReader.ReadElementContentAsBinHex(Byte[], Int32, Int32).)

System_CAPS_pubmethodReadElementContentAsBinHexAsync(Byte[], Int32, Int32)

Asynchronously reads the element and decodes the BinHex content.(Inherited from XmlReader.)

System_CAPS_pubmethodReadElementContentAsBoolean()

Reads the current element and returns the contents as a Boolean object.(Inherited from XmlReader.)

System_CAPS_pubmethodReadElementContentAsBoolean(String, String)

Checks that the specified local name and namespace URI matches that of the current element, then reads the current element and returns the contents as a Boolean object.(Inherited from XmlReader.)

System_CAPS_pubmethodReadElementContentAsDateTime()

Reads the current element and returns the contents as a DateTime object.(Inherited from XmlReader.)

System_CAPS_pubmethodReadElementContentAsDateTime(String, String)

Checks that the specified local name and namespace URI matches that of the current element, then reads the current element and returns the contents as a DateTime object.(Inherited from XmlReader.)

System_CAPS_pubmethodReadElementContentAsDecimal()

Reads the current element and returns the contents as a Decimal object.(Inherited from XmlReader.)

System_CAPS_pubmethodReadElementContentAsDecimal(String, String)

Checks that the specified local name and namespace URI matches that of the current element, then reads the current element and returns the contents as a Decimal object.(Inherited from XmlReader.)

System_CAPS_pubmethodReadElementContentAsDouble()

Reads the current element and returns the contents as a double-precision floating-point number.(Inherited from XmlReader.)

System_CAPS_pubmethodReadElementContentAsDouble(String, String)

Checks that the specified local name and namespace URI matches that of the current element, then reads the current element and returns the contents as a double-precision floating-point number.(Inherited from XmlReader.)

System_CAPS_pubmethodReadElementContentAsFloat()

Reads the current element and returns the contents as single-precision floating-point number.(Inherited from XmlReader.)

System_CAPS_pubmethodReadElementContentAsFloat(String, String)

Checks that the specified local name and namespace URI matches that of the current element, then reads the current element and returns the contents as a single-precision floating-point number.(Inherited from XmlReader.)

System_CAPS_pubmethodReadElementContentAsInt()

Reads the current element and returns the contents as a 32-bit signed integer.(Inherited from XmlReader.)

System_CAPS_pubmethodReadElementContentAsInt(String, String)

Checks that the specified local name and namespace URI matches that of the current element, then reads the current element and returns the contents as a 32-bit signed integer.(Inherited from XmlReader.)

System_CAPS_pubmethodReadElementContentAsLong()

Reads the current element and returns the contents as a 64-bit signed integer.(Inherited from XmlReader.)

System_CAPS_pubmethodReadElementContentAsLong(String, String)

Checks that the specified local name and namespace URI matches that of the current element, then reads the current element and returns the contents as a 64-bit signed integer.(Inherited from XmlReader.)

System_CAPS_pubmethodReadElementContentAsObject()

Reads the current element and returns the contents as an Object.(Inherited from XmlReader.)

System_CAPS_pubmethodReadElementContentAsObject(String, String)

Checks that the specified local name and namespace URI matches that of the current element, then reads the current element and returns the contents as an Object.(Inherited from XmlReader.)

System_CAPS_pubmethodReadElementContentAsObjectAsync()

Asynchronously reads the current element and returns the contents as an Object.(Inherited from XmlReader.)

System_CAPS_pubmethodReadElementContentAsString()

Reads the current element and returns the contents as a String object.(Inherited from XmlReader.)

System_CAPS_pubmethodReadElementContentAsString(String, String)

Checks that the specified local name and namespace URI matches that of the current element, then reads the current element and returns the contents as a String object.(Inherited from XmlReader.)

System_CAPS_pubmethodReadElementContentAsStringAsync()

Asynchronously reads the current element and returns the contents as a String object.(Inherited from XmlReader.)

System_CAPS_pubmethodReadElementString()

Reads a text-only element. However, we recommend that you use the ReadElementContentAsString() method instead, because it provides a more straightforward way to handle this operation.(Inherited from XmlReader.)

System_CAPS_pubmethodReadElementString(String)

Checks that the Name property of the element found matches the given string before reading a text-only element. However, we recommend that you use the ReadElementContentAsString() method instead, because it provides a more straightforward way to handle this operation.(Inherited from XmlReader.)

System_CAPS_pubmethodReadElementString(String, String)

Checks that the LocalName and NamespaceURI properties of the element found matches the given strings before reading a text-only element. However, we recommend that you use the ReadElementContentAsString(String, String) method instead, because it provides a more straightforward way to handle this operation.(Inherited from XmlReader.)

System_CAPS_pubmethodReadEndElement()

Checks that the current content node is an end tag and advances the reader to the next node.(Inherited from XmlReader.)

System_CAPS_pubmethodReadInnerXml()

When overridden in a derived class, reads all the content, including markup, as a string.(Inherited from XmlReader.)

System_CAPS_pubmethodReadInnerXmlAsync()

Asynchronously reads all the content, including markup, as a string.(Inherited from XmlReader.)

System_CAPS_pubmethodReadOuterXml()

When overridden in a derived class, reads the content, including markup, representing this node and all its children.(Inherited from XmlReader.)

System_CAPS_pubmethodReadOuterXmlAsync()

Asynchronously reads the content, including markup, representing this node and all its children.(Inherited from XmlReader.)

System_CAPS_pubmethodReadStartElement()

Checks that the current node is an element and advances the reader to the next node.(Inherited from XmlReader.)

System_CAPS_pubmethodReadStartElement(String)

Checks that the current content node is an element with the given Name and advances the reader to the next node.(Inherited from XmlReader.)

System_CAPS_pubmethodReadStartElement(String, String)

Checks that the current content node is an element with the given LocalName and NamespaceURI and advances the reader to the next node.(Inherited from XmlReader.)

System_CAPS_pubmethodReadString()

Reads the contents of an element or a text node as a string.(Overrides XmlReader.ReadString().)

System_CAPS_pubmethodReadSubtree()

Returns a new XmlReader instance that can be used to read the current node, and all its descendants.(Inherited from XmlReader.)

System_CAPS_pubmethodReadToDescendant(String)

Advances the XmlReader to the next descendant element with the specified qualified name.(Inherited from XmlReader.)

System_CAPS_pubmethodReadToDescendant(String, String)

Advances the XmlReader to the next descendant element with the specified local name and namespace URI.(Inherited from XmlReader.)

System_CAPS_pubmethodReadToFollowing(String)

Reads until an element with the specified qualified name is found.(Inherited from XmlReader.)

System_CAPS_pubmethodReadToFollowing(String, String)

Reads until an element with the specified local name and namespace URI is found.(Inherited from XmlReader.)

System_CAPS_pubmethodReadToNextSibling(String)

Advances the XmlReader to the next sibling element with the specified qualified name.(Inherited from XmlReader.)

System_CAPS_pubmethodReadToNextSibling(String, String)

Advances the XmlReader to the next sibling element with the specified local name and namespace URI.(Inherited from XmlReader.)

System_CAPS_pubmethodReadValueChunk(Char[], Int32, Int32)

Reads large streams of text embedded in an XML document.(Inherited from XmlReader.)

System_CAPS_pubmethodReadValueChunkAsync(Char[], Int32, Int32)

Asynchronously reads large streams of text embedded in an XML document.(Inherited from XmlReader.)

System_CAPS_pubmethodResetState()

Resets the state of the reader to ReadState.Initial.

System_CAPS_pubmethodResolveEntity()

Resolves the entity reference for EntityReference nodes.(Overrides XmlReader.ResolveEntity().)

System_CAPS_pubmethodSkip()

Skips the children of the current node.(Overrides XmlReader.Skip().)

System_CAPS_pubmethodSkipAsync()

Asynchronously skips the children of the current node.(Inherited from XmlReader.)

System_CAPS_pubmethodToString()

Returns a string that represents the current object.(Inherited from Object.)

System_CAPS_noteNote

Starting with the .NET Framework 2.0, we recommend that you create XmlReader instances by using the XmlReader.Create method to take advantage of new functionality.

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 where NodeType is XmlNodeType.EntityReference, a single empty EntityReference node is returned (that is, the Value property is String.Empty).

System_CAPS_noteNote

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 a validating XmlReader.

To read XML data from an XmlDocument, use XmlNodeReader.

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. Use the ReadState property to check whether a reader is in error state.

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

  • Exceptions thrown the XmlTextReader can disclose path information that you do not want bubbled up to the application. Your applications must catch exceptions and process them appropriately.

  • DTD processing is enabled by default. Disable DTD processing if you are concerned about Denial of Service issues or if you are dealing with untrusted sources. Set the DtdProcessing property to Prohibit to disable DTD processing.

    If you have DTD processing enabled, you can use the XmlSecureResolver to restrict the resources that the XmlTextReader can access. You can also design your application so that the XML processing is memory and time constrained. For example, configure time-out limits in your ASP.NET application.

  • XML data can include references to external resources such as a DTD file. By default external resources are resolved using an XmlUrlResolver object with no user credentials. You can secure this further by doing one of the following:

  • XML data can contain a large number of attributes, namespace declarations, nested elements and so on that require a substantial amount of time to process. To limit the size of the input that is sent to the XmlTextReader, create a custom IStream implementation and supply it the XmlTextReader.

  • The ReadValueChunk method can be used to handle large streams of data. This method reads a small number of characters at a time instead of allocating a single string for the whole value.

  • By default general entities are not expanded. General entities are expanded when you call the ResolveEntity method.

Notes to Inheritors:

This class has an inheritance demand. Full trust is required to inherit from XmlTextReader.

.NET Framework
Available since 1.1

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Return to top
Show:
© 2016 Microsoft