This documentation is archived and is not being maintained.

DataSet.ReadXmlSchema Method

Reads an XML schema into the DataSet.

Overload List

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

[Visual Basic] Overloads Public Sub ReadXmlSchema(Stream)
[C#] public void ReadXmlSchema(Stream);
[C++] public: void ReadXmlSchema(Stream*);
[JScript] public function ReadXmlSchema(Stream);

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

Supported by the .NET Compact Framework.

[Visual Basic] Overloads Public Sub ReadXmlSchema(String)
[C#] public void ReadXmlSchema(string);
[C++] public: void ReadXmlSchema(String*);
[JScript] public function ReadXmlSchema(String);

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

[Visual Basic] Overloads Public Sub ReadXmlSchema(TextReader)
[C#] public void ReadXmlSchema(TextReader);
[C++] public: void ReadXmlSchema(TextReader*);
[JScript] public function ReadXmlSchema(TextReader);

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

Supported by the .NET Compact Framework.

[Visual Basic] Overloads Public Sub ReadXmlSchema(XmlReader)
[C#] public void ReadXmlSchema(XmlReader);
[C++] public: void ReadXmlSchema(XmlReader*);
[JScript] public function ReadXmlSchema(XmlReader);

Example

[Visual Basic, C#, C++] 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.

[Visual Basic, C#, C++] Note   This example shows how to use one of the overloaded versions of ReadXmlSchema. For other examples that might be available, see the individual overload topics.
[Visual Basic] 
Private Sub ReadSchemaFromXmlTextReader()
    ' Create the DataSet to read the schema into.
    Dim thisDataSet As New DataSet()
    ' Set the file path and name. Modify this for your purposes.
    Dim filename As String = "mySchema.xml"
    ' Create a FileStream object with the file path and name.
    Dim myFileStream As New System.IO.FileStream _
       (filename, System.IO.FileMode.Open)
    ' Create a new XmlTextReader object with the FileStream.
    Dim myXmlTextReader As New System.Xml.XmlTextReader(myFileStream)
    ' Read the schema into the DataSet and close the reader.
    thisDataSet.ReadXmlSchema(myXmlTextReader)
    myXmlTextReader.Close()
End Sub

[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="mySchema.xml";
   // Create a FileStream object with the file path and name.
   System.IO.FileStream myFileStream = new System.IO.FileStream
      (filename,System.IO.FileMode.Open);
   // Create a new XmlTextReader object with the FileStream.
   System.Xml.XmlTextReader myXmlTextReader= 
      new System.Xml.XmlTextReader(myFileStream);
   // Read the schema into the DataSet and close the reader.
   thisDataSet.ReadXmlSchema(myXmlTextReader);
   myXmlTextReader.Close();
}

[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=S"mySchema.xml";
    // Create a FileStream object with the file path and name.
    System::IO::FileStream* myFileStream = new System::IO::FileStream
       (filename,System::IO::FileMode::Open);
    // Create a new XmlTextReader object with the FileStream.
    System::Xml::XmlTextReader* myXmlTextReader= 
       new System::Xml::XmlTextReader(myFileStream);
    // Read the schema into the DataSet and close the reader.
    thisDataSet->ReadXmlSchema(myXmlTextReader);
    myXmlTextReader->Close();
 }

[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.

See Also

DataSet Class | DataSet Members | System.Data Namespace

Show: