Reputation: 171
i want to read the hierarchies, types and occurences out of a XSD-File. Until now i have only succeded importing the file into an XmlSchemaSet Object, from which i still cannot read the string/int/bool types, neither the max/min occurences or hierarchies.
Example:
<?xml version="1.0" encoding="utf-8"?>
<xs:schema
attributeFormDefault="unqualified"
elementFormDefault="qualified"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
>
<xs:simpleType name="ActionType">
<xs:restriction base="xs:string">
<xs:enumeration value="GET"/>
<xs:enumeration value="POST"/>
</xs:restriction>
</xs:simpleType>
<xs:element name="Data">
<xs:complexType>
<xs:all>
<xs:element name="Action" type="ActionType" minOccurs="1" maxOccurs="1" />
<xs:element name="Target" type="xs:string" minOccurs="1" maxOccurs="1" />
<xs:element name="Parameters" minOccurs="1" maxOccurs="1">
<xs:complexType>
<xs:sequence>
<xs:element name="include_entities" maxOccurs="0" />
<xs:element name="include_user_entities" maxOccurs="0" />
<xs:any processContents="lax" minOccurs="0" maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:all>
</xs:complexType>
Upvotes: 1
Views: 497
Reputation: 1953
You can try using the XSD tool from Microsoft. Save the XSD as XML format and run the XSD tool with the following command:
xsd file.xml /c
It will generate serializable objects for you. Then you could use:
XmlSerializer serializer = new XmlSerializer(XmlClassTypeYouCreatedOnXsdTool);
XmlReader reader = new XmlTextReader(xml);
var instance = serializer.Deserialize(reader);
Remember to start the Visual Studio command prompt in order to have the XSD path set, otherwise you won't be able to find it.
Upvotes: 1