DataSet.ReadXmlSchema Method

Definition

Reads an XML schema into the DataSet.

Overloads

ReadXmlSchema(Stream)

Reads the XML schema from the specified Stream into the DataSet.

ReadXmlSchema(TextReader)

Reads the XML schema from the specified TextReader into the DataSet.

ReadXmlSchema(String)

Reads the XML schema from the specified file into the DataSet.

ReadXmlSchema(XmlReader)

Reads the XML schema from the specified XmlReader into the DataSet.

ReadXmlSchema(Stream)

Source:
DataSet.cs
Source:
DataSet.cs
Source:
DataSet.cs

Reads the XML schema from the specified Stream into the DataSet.

C#
public void ReadXmlSchema(System.IO.Stream? stream);
C#
public void ReadXmlSchema(System.IO.Stream stream);

Parameters

stream
Stream

The Stream from which to read.

Examples

The following example creates a FileStream object to read an XML schema with, and invokes the ReadXmlSchema method with the object.

C#
private void ReadSchemaFromFileStream(DataSet thisDataSet)
{
    // Set the file path and name.
    // Modify this for your purposes.
    string filename="Schema.xml";

    // Create the FileStream object with the file name,
    // and set to open the file.
    System.IO.FileStream stream =
        new System.IO.FileStream(filename,System.IO.FileMode.Open);

    // Read the schema into the DataSet.
    thisDataSet.ReadXmlSchema(stream);

    // Close the FileStream.
    stream.Close();
}

Remarks

Use the ReadXmlSchema method to create the schema for a DataSet. The schema includes table, relation, and constraint definitions. To write a schema to an XML document, use the WriteXmlSchema method.

The XML schema is written using the XSD standard.

Note

Data corruption can occur if the msdata:DataType and the xs:type types do not match. No exception will be thrown.

The ReadXmlSchema method is generally invoked before invoking the ReadXml method which is used to fill the DataSet.

Classes that derive from the Stream class include BufferedStream, FileStream, MemoryStream, and NetworkStream.

Note

If the schema for your DataSet contains elements of the same name, but different type, in the same namespace, an exception is be thrown when you attempt to read the schema into the DataSet with ReadXmlSchema. This exception does not occur if you are using .NET Framework version 1.0.

See also

Applies to

.NET 10 and other versions
Product Versions
.NET Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0, 2.1

ReadXmlSchema(TextReader)

Source:
DataSet.cs
Source:
DataSet.cs
Source:
DataSet.cs

Reads the XML schema from the specified TextReader into the DataSet.

C#
public void ReadXmlSchema(System.IO.TextReader? reader);
C#
public void ReadXmlSchema(System.IO.TextReader reader);

Parameters

reader
TextReader

The TextReader from which to read.

Examples

The following example creates a StreamReader object to read a schema with, and invokes the ReadXmlSchema method with the object.

C#
private void ReadSchemaFromStreamReader()
{
    // Create the DataSet to read the schema into.
    DataSet thisDataSet = new DataSet();

    // Set the file path and name. Modify this for your purposes.
    string filename="Schema.xml";

    // Create a StreamReader object with the file path and name.
    System.IO.StreamReader readStream =
        new System.IO.StreamReader(filename);

    // Invoke the ReadXmlSchema method with the StreamReader object.
    thisDataSet.ReadXmlSchema(readStream);

    // Close the StreamReader
    readStream.Close();
}

Remarks

Use the ReadXmlSchema method to create the schema for a DataSet. The schema includes table, relation, and constraint definitions. To write a schema to an XML document, use the WriteXmlSchema method.

The XML schema is written using the XSD standard.

Note

Data corruption can occur if the msdata:DataType and the xs:type types do not match. No exception will be thrown.

The ReadXmlSchema method is generally invoked before invoking the ReadXml method which is used to fill the DataSet.

Classes that inherit from the TextReader class include the StreamReader and StringReader classes.

Note

If the schema for your DataSet contains elements of the same name, but different type, in the same namespace, an exception is be thrown when you attempt to read the schema into the DataSet with ReadXmlSchema. This exception does not occur if you are using .NET Framework version 1.0.

See also

Applies to

.NET 10 and other versions
Product Versions
.NET Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0, 2.1

ReadXmlSchema(String)

Source:
DataSet.cs
Source:
DataSet.cs
Source:
DataSet.cs

Reads the XML schema from the specified file into the DataSet.

C#
public void ReadXmlSchema(string fileName);

Parameters

fileName
String

The file name (including the path) from which to read.

Exceptions

Examples

C#
private void ReadSchemaFromFile(){
   // Create the DataSet to read the schema into.
   DataSet thisDataSet = new DataSet();

   // Set the file path and name. Modify this for your purposes.
   string filename="Schema.xml";

   // Invoke the ReadXmlSchema method with the file name.
   thisDataSet.ReadXmlSchema(filename);
}

Remarks

Use the ReadXmlSchema method to create the schema for a DataSet. The schema includes table, relation, and constraint definitions. To write a schema to an XML document, use the WriteXmlSchema method.

The XML schema is written using the XSD standard.

Note

Data corruption can occur if the msdata:DataType and the xs:type types do not match. No exception will be thrown.

The ReadXmlSchema method is generally invoked before invoking the ReadXml method which is used to fill the DataSet.

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 ReadXmlSchema. This exception does not occur if you are using .NET Framework version 1.0.

See also

Applies to

.NET 10 and other versions
Product Versions
.NET Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0, 2.1

ReadXmlSchema(XmlReader)

Source:
DataSet.cs
Source:
DataSet.cs
Source:
DataSet.cs

Reads the XML schema from the specified XmlReader into the DataSet.

C#
public void ReadXmlSchema(System.Xml.XmlReader? reader);
C#
public void ReadXmlSchema(System.Xml.XmlReader reader);

Parameters

reader
XmlReader

The XmlReader from which to read.

Examples

The following example creates a new DataSet and System.IO.FileStream object. The FileStream object, created with a file path and file name, is used to create an System.Xml.XmlTextReader that is passed as an argument to the ReadXmlSchema method.

C#
private void ReadSchemaFromXmlTextReader()
{
    // Create the DataSet to read the schema into.
    DataSet thisDataSet = new DataSet();

    // Set the file path and name. Modify this for your purposes.
    string filename="Schema.xml";

    // Create a FileStream object with the file path and name.
    System.IO.FileStream stream = new System.IO.FileStream
        (filename,System.IO.FileMode.Open);

    // Create a new XmlTextReader object with the FileStream.
    System.Xml.XmlTextReader xmlReader=
        new System.Xml.XmlTextReader(stream);

    // Read the schema into the DataSet and close the reader.
    thisDataSet.ReadXmlSchema(xmlReader);
    xmlReader.Close();
}

Remarks

Use the ReadXmlSchema method to create the schema for a DataSet. The schema includes table, relation, and constraint definitions.

The XML schema is written using the XSD standard.

Note

Data corruption can occur if the msdata:DataType and the xs:type types do not match. No exception will be thrown.

The ReadXmlSchema method is generally invoked before invoking the ReadXml method which is used to fill the DataSet.

The System.Xml.XmlReader class is abstract. A class that inherits from the XmlReader is the System.Xml.XmlTextReader class.

Note

If the schema for your DataSet contains elements of the same name, but different type, in the same namespace, an exception is be thrown when you attempt to read the schema into the DataSet with ReadXmlSchema. This exception does not occur if you are using .NET Framework version 1.0.

See also

Applies to

.NET 10 and other versions
Product Versions
.NET Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0, 2.1