XmlSchemaType.GetBuiltInSimpleType Method (XmlTypeCode)

 
System_CAPS_noteNote

The .NET API Reference documentation has a new home. Visit the .NET API Browser on docs.microsoft.com to see the new experience.

Returns an XmlSchemaSimpleType that represents the built-in simple type of the specified simple type.

Namespace:   System.Xml.Schema
Assembly:  System.Xml (in System.Xml.dll)

Public Shared Function GetBuiltInSimpleType (
	typeCode As XmlTypeCode
) As XmlSchemaSimpleType

Parameters

typeCode
Type: System.Xml.Schema.XmlTypeCode

One of the XmlTypeCode values representing the simple type.

Return Value

Type: System.Xml.Schema.XmlSchemaSimpleType

The XmlSchemaSimpleType that represents the built-in simple type.

You cannot directly serialize the built-in type. If you need to serialize the type, create a new simple type which derives from the built-in type and serialize the simple type.

The following example shows how to create the type and add it to the schema.

Imports System
Imports System.Xml
Imports System.Xml.Schema
Module Module1

    Sub Main()

        Dim schema As XmlSchema = New XmlSchema()
        Dim stringType As XmlSchemaSimpleType = New XmlSchemaSimpleType()
        stringType.Name = "myString"
        schema.Items.Add(stringType)
        Dim stringRestriction As XmlSchemaSimpleTypeRestriction = _
                                 New XmlSchemaSimpleTypeRestriction()
        stringRestriction.BaseTypeName = _
                                 New XmlQualifiedName("string", _
                                 "http://www.w3.org/2001/XMLSchema")
        stringType.Content = stringRestriction
        schema.Write(Console.Out)

    End Sub

End Module

.NET Framework
Available since 2.0
Return to top
Show: