Thank you very much for taking a look. Your answer brought me closer to the
solution. I tried your approach and only get the Root of the schema file.
I can not seem to be able to reach the elements.
Please let me know if you know what I do wrong.
"Zafar Abbas" wrote:
> Load the XSD in a XmlSchema object and call Compile(), you can then access
> all global elements via the
> Elements collection.[1]
>
> Given an XSD file called schema.xsd the code looks like:
> Code:
> XmlSchema schema = XmlSchema.Read(new XmlTextReader("schema.xsd"),null);
> schema.Compile();
> foreach (XmlSchemaElement elemenet in schema.Elements.Values)
> {
> // Access the Element properties here , like QualifiedName etc.
> }
>
>
> [1]
>
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemxmlschemaxmlschemaclasselementstopic.asp
>
>
> Thanks.
>
>
> "Mike" <Mike@discussions.microsoft.com> wrote in message
> news:793E2FF6-E95D-482A-AA89-1309DCF5AD15@microsoft.com...
> > Hi! I have an Excel 2003 Schema I need to parse to extract elements names.
> > I am puzzled which System.Xml object can help me. Here's the example of
> my
> > schema:
> >
> > I need to get a collection of element names(TemplateB62,TemplateC62
> .......)
> >
> > <?xml version='1.0' encoding='UTF-8'?>
> > <xsd:schema targetNamespace="
http://tempuri.org/XMLSchema.xsd" > > elementFormDefault="qualified"
> xmlns:xsd="
http://www.w3.org/2001/XMLSchema" > > xmlns="
http://tempuri.org/XMLSchema.xsd"> > > <xsd:annotation>XSD Schema generated with Excel XML
> Toolbox</xsd:annotation>
> > <xsd:element name="Root" type="RootType"/>
> > <xsd:complexType name="RootType">
> > <xsd:all>
> > <xsd:element name="TemplateB62" type="xsd:string" minOccurs="0"
> > nillable="true" form="qualified"/>
> > <xsd:element name="TemplateC62" type="xsd:string" minOccurs="0"
> > nillable="true" form="qualified"/>
> > <xsd:element name="TemplateD62" type="xsd:string" minOccurs="0"
> > nillable="true" form="qualified"/>
> > <xsd:element name="TemplateE62" type="xsd:string" minOccurs="0"
> > nillable="true" form="qualified"/>
> >
> > <xsd:element name="TemplateK86_1" type="xsd:string" minOccurs="0"
> > nillable="true" form="qualified"/>
> > </xsd:all>
> > </xsd:complexType>
> > </xsd:schema>
> >
> >
> > Thank you in advance,
> >
> > --Michael
>
>