As far as programatically parsing an XSD file, try using the
XmlSchemaObjectCollection and XmlSchemaObject classes in the
System.Xml.Schema namespace. Mixed with the familiar manner of using a
FileStream to read in the physical file you can iterate through the
PropertyInfo objects in the collection. This might not be as touchy-feely as
you may be looking for... Look at the sample code in the .NET Framework SDK
for one of the above cited classes and you will get an idea as to what I am
talking about.
I don't know if you've already looked into this but within the DataSet class
members within the System.Data namespace you will notice some methods dealing
directly with schema. Since the internal meta representation of a DataSet is
as schema you can imagine why there is so much support for schemas with
DataSets... This is partly why DataSets are such fat objects. Nevertheless
consider the WriteXmlSchema() method when you already have a DataSet that you
created either from an XML file or a database operation. Like before, using
this method on your DataSet together with a nice FileStream and possibly an
XmlTextWriter you can write out the schema to a physical file or to the
output buffer of your choice.
I hope this helps somewhat.
[quoted text, click to view] "Mad Scientist Jr" wrote:
> I have an XSD dataset file (say "mydataset.xsd") that I want to parse
> with code and loop through the table names, and the relationships,
> constraints, etc.
>
> Can someone point me to any sample code that does something similar?
> Even code that simply reads an XSD file, since I have never done this.
> Do I need to use DOM?
>
> Thanks.
>