This documentation is archived and is not being maintained.

XPathDocument Constructor (TextReader)

.NET Framework 1.1

Initializes a new instance of the XPathDocument class.

[Visual Basic]
Public Sub New( _
   ByVal reader As TextReader _
)
[C#]
public XPathDocument(
   TextReader reader
);
[C++]
public: XPathDocument(
   TextReader* reader
);
[JScript]
public function XPathDocument(
   reader : TextReader
);

Parameters

reader
A TextReader containing the data to load.

Exceptions

Exception Type Condition
XmlException There is a fatal error in the XML. In this case, the XPathDocument remains empty.

Example

The following example loads an XML string into the XPathDocument object using the StringReader class.

[Visual Basic] 
' Load an XML string into the XPathDocument.
Dim xmlString as String = "<date>01-25-2002</date>"
Dim rdr as StringReader = new StringReader(xmlString)
Dim doc as XPathDocument = new XPathDocument(rdr)

[C#] 
// Load an XML string into the XPathDocument.
String xmlString = "<date>01-25-2002</date>";
StringReader rdr = new StringReader(xmlString);
XPathDocument doc = new XPathDocument(rdr);

[C++] 
// Load an XML string into the XPathDocument.
String* xmlString = S"<date>01-25-2002</date>";
StringReader* rdr = new StringReader(xmlString);
XPathDocument* doc = new XPathDocument(rdr);

[JScript] No example is available for JScript. To view a Visual Basic, C#, or C++ example, click the Language Filter button Language Filter in the upper-left corner of the page.

Requirements

Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family

See Also

XPathDocument Class | XPathDocument Members | System.Xml.XPath Namespace | XPathDocument Constructor Overload List

Show: