Writing DataSet Schema Information as XML Schema (XSD)
You can write the schema of aas XML Schema definition language (XSD) schema, so that you can transport it, with or without related data, in an XML document. XML Schema can be written to a file, a stream, an , or a string; it is useful for generating a strongly typed DataSet. For more information about strongly typed DataSet objects, see .
You can specify how a column of a table is represented in XML Schema using the ColumnMapping property of theobject. For more information, see "Mapping Columns to XML Elements, Attributes, and Text" in .
To write the schema of a DataSet as XML Schema, to a file, stream, or XmlWriter, use the WriteXmlSchema method of the DataSet. WriteXmlSchema takes one parameter that specifies the destination of the resulting XML Schema. The following code examples demonstrate how to write the XML Schema of a DataSet to a file by passing a string containing a file name and aobject.
System.IO.StreamWriter writer = new System.IO.StreamWriter("Customers.xsd"); dataSet.WriteXmlSchema(writer); writer.Close();
To obtain the schema of a DataSet and write it as an XML Schema string, use the GetXmlSchema method, as shown in the following example.