Export (0) Print
Expand All

DataSet.GetXmlSchema Method

Returns the XSD schema for the XML representation of the data stored in the DataSet.

[Visual Basic]
Public Function GetXmlSchema() As String
[C#]
public string GetXmlSchema();
[C++]
public: String* GetXmlSchema();
[JScript]
public function GetXmlSchema() : String;

Return Value

String that is the XSD schema for the XML representation of the data stored in the DataSet.

Remarks

Calling this method is identical to calling WriteXmlSchema, except that only the primary schema is written.

Note    GetXmlSchema returns XML as a string, and therefore, requires more overhead than using WriteXmlSchema to write XML to a file.

Example

[Visual Basic, C#, C++] The following example creates a DataSet and DataTable, and then displays the schema in XML format.

[Visual Basic] 
Private Shared Sub DemonstrateGetXmlSchema()
    ' Create a DataSet with one table containing two columns.
    Dim ds As DataSet = New DataSet("myDataSet")
    Dim t As DataTable = ds.Tables.Add("Items")
    t.Columns.Add("id", Type.GetType("System.Int32"))
    t.Columns.Add("Item", Type.GetType("System.String"))

    ' Display the DataSet schema as XML.
    Console.WriteLine( ds.GetXmlSchema() )
End Sub

[C#] 
private static void DemonstrateGetXmlSchema()
{
    // Create a DataSet with one table containing two columns.
    DataSet ds = new DataSet("myDataSet");
    DataTable t = ds.Tables.Add("Items");
    t.Columns.Add("id", typeof(int));
    t.Columns.Add("Item", typeof(string));

    // Display the DataSet schema as XML.
    Console.WriteLine( ds.GetXmlSchema() );
}

[C++] 
public:
    static void DemonstrateGetXmlSchema() {
        // Create a DataSet with one table containing two columns.
        DataSet* ds = new DataSet(S"myDataSet");
        DataTable* t = ds->Tables->Add(S"Items");
        t->Columns->Add(S"id", __typeof(int));
        t->Columns->Add(S"Item", __typeof(String));

        // Display the DataSet schema as XML.
        Console::WriteLine(ds->GetXmlSchema());
    }

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

Requirements

Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family, .NET Compact Framework

See Also

DataSet Class | DataSet Members | System.Data Namespace

Show:
© 2014 Microsoft