To add to what Richard says,
1
and
2
are not value variable or property names, which cannot start with a numeric character.
So your C# code is bad - it won't compile - and the same applies to XML field names which must also start with a letter of underscore.
So your code is bad, yoru data is bad - I'm not surprised that whatever code you are using won't work!
If I correct your xml:
="1.0"="utf-8"
<root>
<main>
<A1>sample</A1>
<A2>sample</A2>
<context>sample</context>
<context>sample</context>
<context>sample</context>
<context>sample</context>
</main>
<main>
<A1>sample</A1>
<A2>sample</A2>
<context>sample</context>
<context>sample</context>
<context>sample</context>
</main>
<main>
<A1>sample</A1>
<A2>sample</A2>
</main>
</root>
And use VS to generate the classes:
[System.Xml.Serialization.XmlTypeAttribute(AnonymousType = true)]
[System.Xml.Serialization.XmlRootAttribute(Namespace = "", IsNullable = false)]
public partial class root
{
private rootMain[] mainField;
[System.Xml.Serialization.XmlElementAttribute("main")]
public rootMain[] main
{
get
{
return this.mainField;
}
set
{
this.mainField = value;
}
}
}
[System.Xml.Serialization.XmlTypeAttribute(AnonymousType = true)]
public partial class rootMain
{
private string a1Field;
private string a2Field;
private string[] contextField;
public string A1
{
get
{
return this.a1Field;
}
set
{
this.a1Field = value;
}
}
public string A2
{
get
{
return this.a2Field;
}
set
{
this.a2Field = value;
}
}
[System.Xml.Serialization.XmlElementAttribute("context")]
public string[] context
{
get
{
return this.contextField;
}
set
{
this.contextField = value;
}
}
}
Then the rootMain class looks like your TUs class.
(VS can generate XML classes for you from XML data - create a new empty class file, and select "Edit...Paste Special...Paste XML as classes" from the menu bar and it will generate classes based on the clipboard data.)