It is possible using some undocumented pieces of the System.Xml namespace.
This is a C# code snippet; translation to VB.NET is left to you.
Type cusType = typeof(MyType);
XmlReflectionImporter imp = new XmlReflectionImporter();
XmlSchemas schemas = new XmlSchemas();
XmlSchemaExporter exp = new XmlSchemaExporter(schemas);
XmlTypeMapping xmlTypeMapping = imp.ImportTypeMapping(cusType);
exp.ExportTypeMapping(xmlTypeMapping);
TextWriter tw = new StreamWriter("MyType.xsd");
schemas[0].Write(tw);
tw.Close();
source:
http://www.xmlwebservices.cc/index_FAQ.htm -Dino
[quoted text, click to view] "HJ Rodriguez" <hanklvr@yahoo.com> wrote in message
news:%23mKtNdrEEHA.3256@TK2MSFTNGP09.phx.gbl...
> Hello all,
>
> I have the following serializable class.
> --------------------------------------------------------------------------
--
> --
> Public Class Test
>
> _testID as int32
> _testName as String
>
> Public Sub New()
> MyBase.New()
> End Sub
>
> <XmlAttributeAttribute()> Public Property TestID() As int32
> Get
> Return _testID
> End Get
> Set(ByVal Value As int32)
> _testID= value
> End Set
> End Property
>
> <XmlAttributeAttribute()> Public Property TestName() As String
> Get
> Return _testName
> End Get
> Set(ByVal Value As String)
> _testName= value
> End Set
> End Property
> End Class
> --------------------------------------------------------------------------
--
> -
>
> I know I can use XSD.exe to build an XSD file from this class at design
> time. But is their any way to build an XSD schema at runtime (in memroy)
> based on my class.
>
> I know I can use reflection to query the members of my objects and build
my
> schema, but I was hoping that there might me something in the .net
framework
> which can acomplish this more efficiently.
>
> Thank you in advance for your help.
>
> Reguards,
> HJ Rodriguez
>
>