System.Data Namespace DataSet Class
Writes the DataSet structure as an XML schema to an XmlWriter object.
[ VB ]
Overloads Public Sub WriteXmlSchema ( _
ByVal writer As XmlWriter _
)
[ C# ]
public void WriteXmlSchema (
XmlWriter writer
);
[ C++ ]
public: void WriteXmlSchema (
XmlWriter* writer
);
[ JScript ]
public function WriteXmlSchema (
writer : XmlWriter
);
- writer
- The XmlWriter with which to write.
Use the WriteXmlSchema method to write the schema for a DataSet to an XML document. 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.
To write the data to an XML document, use the WriteXml method.
One class that inherits from the System.Xml.XmlWriter class is the System.Xml.XmlTextWriter class.
The following example initializes a new System.IO.FileStream object with the specified path, which is used to create an XmlTextWriter object. The WriteXmlSchema method is then invoked with the XmlTextWriter object to write the schema to the disk.
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 writer.
thisDataSet.WriteXmlSchema ( myXmlTextWriter );
myXmlTextWriter.Close ( );
}
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 writer.
thisDataSet.WriteXmlSchema ( myXmlTextWriter )
myXmlTextWriter.Close ( )
End Sub |
|
C# |
VB |
DataSet Members DataSet.WriteXmlSchema Overload List WriteXml ReadXml ReadXmlSchema