DataSet 構造体を XML スキーマとして XmlWriter オブジェクトに書き込みます。
Overloads Public Sub WriteXmlSchema( _
ByVal writer As XmlWriter _)
[C#]
public void WriteXmlSchema(XmlWriterwriter);
[C++]
public: void WriteXmlSchema(XmlWriter* writer);
[JScript]
public function WriteXmlSchema(
writer : XmlWriter);
パラメータ
- writer
書き込みに使用する XmlWriter 。
解説
WriteXmlSchema メソッドを使用して、 DataSet のスキーマを XML ドキュメントに書き込みます。スキーマにはテーブル、リレーションシップ、制約の各定義が含まれています。XML ドキュメントにスキーマを書き込むには、 WriteXmlSchema メソッドを使用します。
XML スキーマの書き込みには、XSD 標準を使用します。
XML ドキュメントにデータを書き込むには、 WriteXml メソッドを使用します。
System.Xml.XmlWriter クラスから継承するクラスには System.Xml.XmlTextWriter クラスがあります。
使用例
[Visual Basic, C#, C++] 指定したパスで新しい System.IO.FileStream オブジェクトを作成する例を次に示します。 FileStream オブジェクトを使用して System.Xml.XMLTextWriter オブジェクトを作成します。次に、 XmlTextWriter オブジェクトで WriteXmlSchema メソッドを呼び出して、ディスクにスキーマを書き込みます。
Private Sub WriteSchemaWithXmlTextWriter(thisDataSet As 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.Create)
' Create a new XmlTextWriter object with the FileStream.
Dim MyXmlTextWriter As New System.Xml.XmlTextWriter _
(myFileStream, System.Text.Encoding.Unicode)
' Write the schema into the DataSet and close the reader.
thisDataSet.WriteXmlSchema(MyXmlTextWriter)
MyXmlTextWriter.Close()
End Sub
[C#]
private void WriteSchemaWithXmlTextWriter(DataSet thisDataSet){
// 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.Create);
// Create a new XmlTextWriter object with the FileStream.
System.Xml.XmlTextWriter MyXmlTextWriter =
new System.Xml.XmlTextWriter(myFileStream, System.Text.Encoding.Unicode);
// Write the schema into the DataSet and close the reader.
thisDataSet.WriteXmlSchema(MyXmlTextWriter );
MyXmlTextWriter.Close();
}
[C++]
private:
void WriteSchemaWithXmlTextWriter(DataSet* thisDataSet){
// 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::Create);
// Create a new XmlTextWriter object with the FileStream.
System::Xml::XmlTextWriter* MyXmlTextWriter =
new System::Xml::XmlTextWriter(myFileStream, System::Text::Encoding::Unicode);
// Write the schema into the DataSet and close the reader.
thisDataSet->WriteXmlSchema(MyXmlTextWriter );
MyXmlTextWriter->Close();
}
[JScript] JScript のサンプルはありません。Visual Basic、C#、および C++ のサンプルを表示するには、このページの左上隅にある言語のフィルタ ボタン をクリックします。
必要条件
プラットフォーム: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 ファミリ, .NET Compact Framework - Windows CE .NET
参照
DataSet クラス | DataSet メンバ | System.Data 名前空間 | DataSet.WriteXmlSchema オーバーロードの一覧 | ReadXml | ReadXmlSchema | WriteXml