Deserialization class is collecting just the first element from the xml.
[XmlElement("typ")]
public string Typ
{
get { return typ; }
set { typ = value; }
}
[XmlElement("mak")]
public string Mak
{
get { return mak; }
set { mak = value; }
}My xml file.....
<instruz>
<inst>
<Ins>Instrument 1</Ins>
<typ>Instrument 1 Type 1</typ>
<typ>Instrument 1 Type 2</typ> //This option is not displayed
<typ>Instrument 1 Type 3</typ> //This option is not displayed
<mak>Instrument 1 Type 1 Make 1</mak>
<mak>Instrument 1 Type 1 Make 2</mak> //This option is not displayed
<mak>Instrument 1 Type 1 Make 3</mak> //This option is not displayed
<mak>Instrument 1 Type 2 Make 1</mak> //This option is not displayed
<mak>Instrument 1 Type 2 Make 2</mak> //This option is not displayed
<mak>Instrument 1 Type 3 Make 3</mak> //This option is not displayed
</inst>
<inst>
<Ins>Instrument 2</Ins>
<typ>Instrument 2 Type 1</typ>
<typ>Instrument 2 Type 2</typ> //This option is not displayed
<typ>Instrument 2 Type 3</typ> //This option is not displayed
<typ>Instrument 2 Type 4</typ> //This option is not displayed
<mak>Instrument 2 Type 1 Make 1</mak>
<mak>Instrument 2 Type 1 Make 2</mak> //This option is not displayed
<mak>Instrument 2 Type 1 Make 3</mak> //This option is not displayed
<mak>Instrument 2 Type 2 Make 1</mak> //This option is not displayed
<mak>Instrument 2 Type 2 Make 2</mak> //This option is not displayed
<mak>Instrument 2 Type 3 Make 3</mak> //This option is not displayed
<mak>Instrument 2 Type 4 Make 1</mak> //This option is not displayed
<mak>Instrument 2 Type 4 Make 5</mak> //This option is not displayed
</inst>
</instruz>
Im havng three comboBox in my winform. cb1, cb2, cb3.
cb1 displays <Ins> field
cb2 displays <typ> field
cb3 displays <mak> field
But cb2 & cb3 are not fetching all the elements in <typ> / <mak> fields.

2 answers
The problem there is that there are multiple 'typ' and 'mak' child nodes in each 'inst' node. You therefore need to use List<string>'s rather than scalar string variables.
This is how I would deserialize your xml file, using a console app:
EDIT - see comments below
I'd suggest the following to fit this code into the context of your WF application:
answered one year ago by:
17279
412
and now as I'm displaying these fields in the ComboBox I would need to specify the Datasourse also.... what should I take as the DataSource for these three different combobox??? If I do something like this then also the Datasource is not recognised " foreach (Instrument inst in instruments.InstList) { comboBox1.DataSource = inst.Ins; }"
17279
The DataSource for cb1 will be instruments.InstList and the DisplayMember will be "Ins". The DataSource for cb2 and cb3 will change depending on what cb1 is currently showing. Please see my edit.
A script error is always displayed here in my debugging.com's account.....
Line: 88
Char: 27
Error: Expected Identifier, String or Number
Code: 0
Due to this I'm not able to rate the answer, Mark answer as accepted, nor I'm able to add any comment.
Admin... please do something about it.
answered one year ago by:
412