How to list element names from an xml schema

Q

Quinn

if I have a schema like this:

<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:element name="Root">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="Version" type="xsd:string"/>
<xsd:element name="VerDate" type="xsd:date"/>
<xsd:element minOccurs="0" maxOccurs="unbounded"
name="SoftwareInfo">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="No" type="xsd:integer"/>
<xsd:element name="Type" type="xsd:string"/>
<xsd:element name="Name" type="xsd:decimal" />
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:element>
</xsd:schema>


How do I loop through each element and print something like this:

Root
Version
Verdate
....

Thanks.
 
J

John Saunders [MVP]

Quinn said:
if I have a schema like this:

<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:element name="Root">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="Version" type="xsd:string"/>
<xsd:element name="VerDate" type="xsd:date"/>
<xsd:element minOccurs="0" maxOccurs="unbounded"
name="SoftwareInfo">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="No" type="xsd:integer"/>
<xsd:element name="Type" type="xsd:string"/>
<xsd:element name="Name" type="xsd:decimal" />
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:element>
</xsd:schema>


How do I loop through each element and print something like this:

Root
Version
Verdate

Take a look at the documentation of the XmlSchema class, at
XmlSchema.http://msdn2.microsoft.com/en-us/library/system.xml.schema.xmlschema.aspx.
You can load a schema via the Read method
(http://msdn2.microsoft.com/en-us/library/system.xml.schema.xmlschema.read.aspx).
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top