XmlReader Class

[This documentation is for preview only, and is subject to change in later releases. Blank topics are included as placeholders.]

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

System..::..Object
  System.Xml..::..XmlReader

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

public ref class XmlReader : IDisposable

The XmlReader type exposes the following members.

  NameDescription
Public propertyAttributeCountWhen overridden in a derived class, gets the number of attributes on the current node.
Public propertyDepthWhen overridden in a derived class, gets the depth of the current node in the XML document.
Public propertyEOFWhen overridden in a derived class, gets a value indicating whether the reader is positioned at the end of the stream.
Public propertyHasAttributesGets a value indicating whether the current node has any attributes.
Public propertyHasValueWhen overridden in a derived class, gets a value indicating whether the current node can have a Value.
Public propertyIsEmptyElementWhen overridden in a derived class, gets a value indicating whether the current node is an empty element (for example, <MyElement/>).
Public propertyLocalNameWhen overridden in a derived class, gets the local name of the current node.
Public propertyNameWhen overridden in a derived class, gets the qualified name of the current node.
Public propertyNamespaceURIWhen overridden in a derived class, gets the namespace URI (as defined in the W3C Namespace specification) of the node on which the reader is positioned.
Public propertyNameTableWhen overridden in a derived class, gets the XmlNameTable associated with this implementation.
Public propertyNodeTypeWhen overridden in a derived class, gets the type of the current node.
Public propertyPrefixWhen overridden in a derived class, gets the namespace prefix associated with the current node.
Public propertyReadStateWhen overridden in a derived class, gets the state of the reader.
Public propertyValueWhen overridden in a derived class, gets the text value of the current node.
Public propertyXmlLangWhen overridden in a derived class, gets the current xml:lang scope.
Public propertyXmlSpaceWhen overridden in a derived class, gets the current xml:space scope.
Top

  NameDescription
Public methodCloseWhen overridden in a derived class, changes the ReadState to Closed.
Public methodStatic memberCreate(Stream)Creates a new XmlReader instance using the specified stream.
Public methodStatic memberCreate(Stream, XmlReaderSettings)Creates a new XmlReader instance with the specified stream and XmlReaderSettings object.
Public methodDisposeReleases all resources used by the current instance of the XmlReader class.
Public methodEquals(Object)Determines whether the specified Object is equal to the current Object. (Inherited from Object.)
Protected methodFinalizeAllows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.)
Public methodGetAttribute(Int32)When overridden in a derived class, gets the value of the attribute with the specified index.
Public methodGetAttribute(String)When overridden in a derived class, gets the value of the attribute with the specified Name.
Public methodGetAttribute(String, String)When overridden in a derived class, gets the value of the attribute with the specified LocalName and NamespaceURI.
Public methodGetHashCodeServes as a hash function for a particular type. (Inherited from Object.)
Public methodGetTypeGets the Type of the current instance. (Inherited from Object.)
Public methodIsStartElement()()()()Calls MoveToContent and tests if the current content node is a start tag or empty element tag.
Public methodIsStartElement(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.
Public methodIsStartElement(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.
Public methodLookupNamespaceWhen overridden in a derived class, resolves a namespace prefix in the current element's scope.
Protected methodMemberwiseCloneCreates a shallow copy of the current Object. (Inherited from Object.)
Public methodMoveToAttribute(Int32)When overridden in a derived class, moves to the attribute with the specified index.
Public methodMoveToAttribute(String)When overridden in a derived class, moves to the attribute with the specified Name.
Public methodMoveToAttribute(String, String)When overridden in a derived class, moves to the attribute with the specified LocalName and NamespaceURI.
Public methodMoveToContentChecks 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.
Public methodMoveToElementWhen overridden in a derived class, moves to the element that contains the current attribute node.
Public methodMoveToFirstAttributeWhen overridden in a derived class, moves to the first attribute.
Public methodMoveToNextAttributeWhen overridden in a derived class, moves to the next attribute.
Public methodReadWhen overridden in a derived class, reads the next node from the stream.
Public methodReadElementString()()()()Reads a text-only element.
Public methodReadElementString(String)Checks that the Name property of the element found matches the given string before reading a text-only element.
Public methodReadElementString(String, String)Checks that the LocalName and NamespaceURI properties of the element found matches the given strings before reading a text-only element.
Public methodReadEndElementChecks that the current content node is an end tag and advances the reader to the next node.
Public methodReadStartElement()()()()Checks that the current node is an element and advances the reader to the next node.
Public methodReadStartElement(String)Checks that the current content node is an element with the given Name and advances the reader to the next node.
Public methodReadStartElement(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.
Public methodReadStringWhen overridden in a derived class, reads the contents of an element or text node as a string.
Public methodReadToDescendant(String)Advances the XmlReader to the next descendant element with the specified qualified name.
Public methodReadToDescendant(String, String)Advances the XmlReader to the next descendant element with the specified local name and namespace URI.
Public methodReadToFollowing(String)Reads until an element with the specified qualified name is found.
Public methodReadToFollowing(String, String)Reads until an element with the specified local name and namespace URI is found.
Public methodReadToNextSibling(String)Advances the XmlReader to the next sibling element with the specified qualified name.
Public methodReadToNextSibling(String, String)Advances the XmlReader to the next sibling element with the specified local name and namespace URI.
Public methodSkipSkips the children of the current node.
Public methodToStringReturns a string that represents the current object. (Inherited from Object.)
Top

XmlReader provides forward-only, read-only access to a stream of XML data. The XmlReader class conforms to the W3C Extensible Markup Language (XML) 1.0 and the Namespaces in XML recommendations.

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.

XmlReader 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 the reader is in error state.

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