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.
Inheritance Hierarchy
System. . :: . .Object
System.Xml..::..XmlReader
Namespace: System.Xml
Assembly: System.Xml (in System.Xml.dll)
Syntax
'Declaration
Public Class XmlReader _
Implements IDisposable
public class XmlReader : IDisposable
public ref class XmlReader : IDisposable
type XmlReader =
class
interface IDisposable
end
public class XmlReader implements IDisposable
The XmlReader type exposes the following members.
Properties
Name | Description | |
---|---|---|
AttributeCount | When overridden in a derived class, gets the number of attributes on the current node. | |
Depth | When overridden in a derived class, gets the depth of the current node in the XML document. | |
EOF | When overridden in a derived class, gets a value indicating whether the reader is positioned at the end of the stream. | |
HasAttributes | Gets a value indicating whether the current node has any attributes. | |
HasValue | When overridden in a derived class, gets a value indicating whether the current node can have a Value. | |
IsEmptyElement | When overridden in a derived class, gets a value indicating whether the current node is an empty element (for example, <MyElement/>). | |
LocalName | When overridden in a derived class, gets the local name of the current node. | |
Name | When overridden in a derived class, gets the qualified name of the current node. | |
NamespaceURI | When 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. | |
NameTable | When overridden in a derived class, gets the XmlNameTable associated with this implementation. | |
NodeType | When overridden in a derived class, gets the type of the current node. | |
Prefix | When overridden in a derived class, gets the namespace prefix associated with the current node. | |
ReadState | When overridden in a derived class, gets the state of the reader. | |
Value | When overridden in a derived class, gets the text value of the current node. | |
XmlLang | When overridden in a derived class, gets the current xml:lang scope. | |
XmlSpace | When overridden in a derived class, gets the current xml:space scope. |
Top
Methods
Name | Description | |
---|---|---|
Close | When overridden in a derived class, changes the ReadState to Closed. | |
Create(Stream) | Creates a new XmlReader instance using the specified stream. | |
Create(Stream, XmlReaderSettings) | Creates a new XmlReader instance with the specified stream and XmlReaderSettings object. | |
Dispose | Releases all resources used by the current instance of the XmlReader class. | |
Equals(Object) | Determines whether the specified Object is equal to the current Object. (Inherited from Object.) | |
Finalize | Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.) | |
GetAttribute(Int32) | When overridden in a derived class, gets the value of the attribute with the specified index. | |
GetAttribute(String) | When overridden in a derived class, gets the value of the attribute with the specified Name. | |
GetAttribute(String, String) | When overridden in a derived class, gets the value of the attribute with the specified LocalName and NamespaceURI. | |
GetHashCode | Serves as a hash function for a particular type. (Inherited from Object.) | |
GetType | Gets the Type of the current instance. (Inherited from Object.) | |
IsStartElement() () () () | Calls MoveToContent and tests if the current content node is a start tag or empty element tag. | |
IsStartElement(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. | |
IsStartElement(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. | |
LookupNamespace | When overridden in a derived class, resolves a namespace prefix in the current element's scope. | |
MemberwiseClone | Creates a shallow copy of the current Object. (Inherited from Object.) | |
MoveToAttribute(Int32) | When overridden in a derived class, moves to the attribute with the specified index. | |
MoveToAttribute(String) | When overridden in a derived class, moves to the attribute with the specified Name. | |
MoveToAttribute(String, String) | When overridden in a derived class, moves to the attribute with the specified LocalName and NamespaceURI. | |
MoveToContent | 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. | |
MoveToElement | When overridden in a derived class, moves to the element that contains the current attribute node. | |
MoveToFirstAttribute | When overridden in a derived class, moves to the first attribute. | |
MoveToNextAttribute | When overridden in a derived class, moves to the next attribute. | |
Read | When overridden in a derived class, reads the next node from the stream. | |
ReadElementString() () () () | Reads a text-only element. | |
ReadElementString(String) | Checks that the Name property of the element found matches the given string before reading a text-only element. | |
ReadElementString(String, String) | Checks that the LocalName and NamespaceURI properties of the element found matches the given strings before reading a text-only element. | |
ReadEndElement | Checks that the current content node is an end tag and advances the reader to the next node. | |
ReadStartElement() () () () | Checks that the current node is an element and advances the reader to the next node. | |
ReadStartElement(String) | Checks that the current content node is an element with the given Name and advances the reader to the next node. | |
ReadStartElement(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. | |
ReadString | When overridden in a derived class, reads the contents of an element or text node as a string. | |
ReadToDescendant(String) | Advances the XmlReader to the next descendant element with the specified qualified name. | |
ReadToDescendant(String, String) | Advances the XmlReader to the next descendant element with the specified local name and namespace URI. | |
ReadToFollowing(String) | Reads until an element with the specified qualified name is found. | |
ReadToFollowing(String, String) | Reads until an element with the specified local name and namespace URI is found. | |
ReadToNextSibling(String) | Advances the XmlReader to the next sibling element with the specified qualified name. | |
ReadToNextSibling(String, String) | Advances the XmlReader to the next sibling element with the specified local name and namespace URI. | |
Skip | Skips the children of the current node. | |
ToString | Returns a string that represents the current object. (Inherited from Object.) |
Top
Remarks
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.
Thread Safety
Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.