Mono Class Library: System.Xml Namespace

System.Xml.XmlReader Class

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

See Also: XmlReader Members

public abstract class XmlReader : IDisposable

Thread Safety

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

Remarks

This class provides forward-only, read-only access to a stream of XML data. This class enforces the rules of well-formed XML but does not perform data validation.

This class conforms to the W3C Extensible Markup Language (XML) 1.0 and the Namespaces in XML recommendations.

A given set of XML data is modeled as a tree of nodes. The different types of nodes are specified in the System.Xml.XmlNodeType enumeration. The reader is advanced to the next node using the XmlReader.Read method. The current node refers to the node on which the reader is positioned. The following table lists the node properties exposed for the current node.

PropertyDescription
AttributeCount The number of attributes on the node.
BaseUriThe base URI of the node.
DepthThe depth of the node in the tree.
HasAttributesWhether the node has attributes.
HasValueWhether the node can have a text value.
IsDefaultWhether an Attribute node was generated from the default value defined in the DTD or schema.
IsEmptyElementWhether an Element node is empty.
LocalNameThe local name of the node.
NameThe qualified name of the node, equal to Prefix:LocalName.
NamespaceUriThe URI defining the namespace associated with the node.
NodeTypeThe System.Xml.XmlNodeType of the node.
PrefixA shorthand reference to the namespace associated with the node.
QuoteCharThe quotation mark character used to enclose the value of an attribute.
ValueThe text value of the node.
XmlLangThe xml:lang scope within which the node resides.

This class does not expand default attributes or general entities. Any general entities encountered are returned as a single empty EntityReference node.

This class checks that a Document Type Definition (DTD) is well-formed, but does not validate using the DTD.

To read strongly typed data, use the System.Xml.XmlConvert class.

This class throws a 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 might be different than the actual node type of the current node.

Note:

This class is abstract and implemented in the System.Xml.XmlTextReader class.

[Edit]

Requirements

Namespace: System.Xml
Assembly: System.Xml (in System.Xml.dll)
Assembly Versions: 1.0.5000.0, 2.0.0.0