Export (0) Print
Expand All

XPathDocument Constructor (XmlReader)

Initializes a new instance of the XPathDocument class from the XML data that is contained in the specified XmlReader object.

Namespace: System.Xml.XPath
Assembly: System.Xml (in system.xml.dll)

public XPathDocument (
	XmlReader reader
)
public XPathDocument (
	XmlReader reader
)
public function XPathDocument (
	reader : XmlReader
)

Parameters

reader

The XmlReader object that contains the XML data.

Exception typeCondition

XmlException

An error was encountered in the XML data. The XPathDocument remains empty.

ArgumentNullException

The XmlReader object passed as a parameter is a null reference (Nothing in Visual Basic).

An XmlReader object can be used to load a whole XML document into an XPathDocument, or part of an XML document. To load part of an XML document into an XPathDocument, position the XmlReader object on the top XML node to load data from. When you create an XPathDocument using the XPathDocument constructor, data is loaded from the current top node until the top node's closing tag is reached. Data from all child nodes is included.

The following are important notes to consider when you use the XPathDocument constructor.

  • An XmlReader object with the appropriate associated XmlResolver object settings can be used to resolve entities or other references in XML data.

  • If the XmlReader object is positioned on a leaf node that is not valid for the root level of a document—for example, a white space or attribute node—the XmlReader object continues to read until it is positioned on a node that can be used for the root. The XPathDocument begins loading at this point.

  • To preserve white space, use the XPathDocument constructor that accepts an XmlSpace object as a parameter.

Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.

.NET Framework

Supported in: 2.0, 1.1, 1.0

Community Additions

ADD
Show:
© 2014 Microsoft