This documentation is archived and is not being maintained.

DataSet.ReadXml Method (Stream, XmlReadMode)

.NET Framework 1.1

Reads XML schema and data into the DataSet using the specified System.IO.Stream and XmlReadMode.

[Visual Basic]
Overloads Public Function ReadXml( _
   ByVal stream As Stream, _
   ByVal mode As XmlReadMode _
) As XmlReadMode
public XmlReadMode ReadXml(
 Stream stream,
 XmlReadMode mode
public: XmlReadMode ReadXml(
 Stream* stream,
 XmlReadMode mode
public function ReadXml(
   stream : Stream,
 mode : XmlReadMode
) : XmlReadMode;


The Stream from which to read.
One of the XmlReadMode values.

Return Value

The XmlReadMode used to read the data.


The ReadXml method provides a way to read either data only, or both data and schema into a DataSet from an XML document, whereas the ReadXmlSchema method reads only the schema. To read both data and schema, use one of the ReadXML overloads that includes the XmlReadMode parameter, and set its value to ReadSchema.

Note that the same is true for the WriteXml and WriteXmlSchema methods, respectively. To write XML data, or both schema and data from the DataSet, use the WriteXml method. To write just the schema, use the WriteXmlSchema method.

If an in-line schema is specified, the in-line schema is used to extend the existing relational structure prior to loading the data. If there are any conflicts (for example, the same column in the same table defined with different datatypes) an exception is raised.

If no in-line schema is specified, the relational structure is extended through inference, as necessary, according to the structure of the XML document. If the schema cannot be extended through inference in order to expose all data, an exception is raised.

If the XSD schema for a DataSet includes a targetNamespace, data may not be read, and you may encounter exceptions when calling ReadXml to load the DataSet with XML that contains elements with no qualifying namespace. To read unqualified elements, set elementFormDefault equal to "qualified" in your XSD schema as the following example demonstrates.

<xsd:schema id="MyDataSet" 
Note   If the schema for your DataSet contains elements of the same name, but different type, in the same namespace, an exception is thrown when you attempt to read the schema into the DataSet with ReadXml by specifying XmlReadMode.ReadSchema. This exception does not occur if you are using .NET Framework version 1.0.


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

DataSet Class | DataSet Members | System.Data Namespace | DataSet.ReadXml Overload List