I have tried to generated a class from your xml.
At the beginning I have generated an xsd from your xml
<?xml version="1.0" encoding="utf-8"?>
<xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="GeneralTranslation">
<xs:complexType>
<xs:sequence>
<xs:element name="Day" type="xs:string" />
<xs:element name="Month" type="xs:string" />
<xs:element name="Year" type="xs:string" />
<xs:element name="Submit" type="xs:string" />
<xs:element name="Select" type="xs:string" />
<xs:element name="TradingExp">
<xs:complexType>
<xs:sequence>
<xs:element maxOccurs="unbounded" name="Option" type="xs:string" />
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="LevelOfInvestment">
<xs:complexType>
<xs:sequence>
<xs:element maxOccurs="unbounded" name="Option" type="xs:string" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
then using xsd utility I have generated the following class
[System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "2.0.50727.3038")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
[System.Xml.Serialization.XmlTypeAttribute(AnonymousType=true)]
[System.Xml.Serialization.XmlRootAttribute(Namespace="", IsNullable=false)]
public partial class GeneralTranslation {
private string dayField;
private string monthField;
private string yearField;
private string submitField;
private string selectField;
private string[] tradingExpField;
private string[] levelOfInvestmentField;
/// <remarks/>
public string Day {
get {
return this.dayField;
}
set {
this.dayField = value;
}
}
/// <remarks/>
public string Month {
get {
return this.monthField;
}
set {
this.monthField = value;
}
}
/// <remarks/>
public string Year {
get {
return this.yearField;
}
set {
this.yearField = value;
}
}
/// <remarks/>
public string Submit {
get {
return this.submitField;
}
set {
this.submitField = value;
}
}
/// <remarks/>
public string Select {
get {
return this.selectField;
}
set {
this.selectField = value;
}
}
/// <remarks/>
[System.Xml.Serialization.XmlArrayItemAttribute("Option", IsNullable=false)]
public string[] TradingExp {
get {
return this.tradingExpField;
}
set {
this.tradingExpField = value;
}
}
/// <remarks/>
[System.Xml.Serialization.XmlArrayItemAttribute("Option", IsNullable=false)]
public string[] LevelOfInvestment {
get {
return this.levelOfInvestmentField;
}
set {
this.levelOfInvestmentField = value;
}
}
}
}
so out of here you can get string arrays, but not list
below there is the the how-to:
- Open your XML in Visual Studio
- Select the tab with your XML. In main menu select XML/Create Schema. (the studio will open you the scheme file)
- use xsd.exe util. (http://msdn.microsoft.com/en-us/library/x6c1kb0s(v=vs.110).aspx)
in some cases I am doing the following trick with xsd's:
when I know that my document schmema can be changed during development cycle:
I am adding XSD file into my project.
In project file I am adding the following sections
<PropertyGroup>
<WIN_SDK_PATH>$(Registry:HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SDKs\Windows@CurrentInstallFolder)</WIN_SDK_PATH>
<WIN_SDK_BIN_PATH>$(WIN_SDK_PATH)bin</WIN_SDK_BIN_PATH>
<XSDUTIL>"$(WIN_SDK_BIN_PATH)\xsd.exe"</XSDUTIL>
</PropertyGroup>
<Target Name="XSD2CS">
<Exec Command="$(XSDUTIL) "$(ProjectDir)XMLSchema1.xsd" /classes /out:"$(ProjectDir)obj" /namespace:$(RootNamespace).XSD" />
</Target>
<Target Name="BeforeBuild" DependsOnTargets="XSD2CS">
</Target>
and one more section in the that contain my project files
<Compile Include="$(ProjectDir)obj\XMLSchema1.cs">
<SubType>Code</SubType>
</Compile>
each time when I am compiling my project I am getting a class that corresponds the latest actual version of my xsd. so all I need to take care of is a correct and full xsd file.