Mono Class Library: System.Xml.XmlDocument Overview | Members

System.Xml.XmlDocument.ReadNode Method

Read an XML node from argument System.Xml.XmlReader and returns it as an System.Xml.XmlNode object. [Edit]

public virtual XmlNode ReadNode (XmlReader reader)

Parameters

reader
An System.Xml.XmlReader to read. [Edit]

Returns

An System.Xml.XmlNode object that represents the node in the argument XmlReader, or null if the reader is not ready to be consumed. [Edit]

Remarks

This method consumes current node in the argument XmlReader and creates an instance of one of the derived class of System.Xml.XmlNode. The returned node contains all of the children. After this method was invoked, the argument XmlReader is positioned either at the next sibling node in the tree, or at the XmlNodeType.EndElement of the parent element.

If the argument XmlReader is at ReadState.Initial state, then first it moves to the first node and then consumes it as current node.

Unlike XmlTextReader.Read, this method rejects such entity reference nodes whose referenced entity does not exist. In such cases, an System.Xml.XmlException is thrown.

For entity reference nodes, if the argument XmlReader can resolve entities as indicated by XmlReader.CanResolveEntity property, it resolves the entity using XmlReader.ResolveEntity method and appends the resolved children as the content of the node, instead of the entity reference node itself.

If the argument XmlReader is positioned at XmlNodeType.EndElement, a NullReferenceException is thrown.

If the argument XmlReader is neither in the state of ReadState.Initial nor the state of ReadState.Interactive, then it returns null.

[Edit]

Requirements

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