I need to read data from XML to a List<>. The XML file contains three table format XML:
<?xml version="1.0" standalone="yes"?>
<Test>
<Table1>
<Column_tb1>8</Column_tb1>
</Table1>
<Table2>
<Column_tb2_AA>1</Column_tb2_AA>
<Column_tb2_BB>11</Column_tb2_BB>
</Table2>
<Table2>
<Column_tb2_AA>2</Column_tb2_AA>
<Column_tb2_BB>22</Column_tb2_BB>
</Table2>
<Table3>
<Column_tb3_AA>2</Column_tb1_AA>
<Column_tb3_BB>1</Column_tb1_BB>
<Column_tb3_CC>25</Column_tb1_CC>
</Table3>
</Test>
Dataset can read that quite simple,
DataSet dsProfile = new DataSet();
dsProfile.ReadXml(strProfile);
By this way three datatables will in dsprofile automatic. How can use a list as a container to save XML file data? if only one table format, i can do that:
List<Table1> listtable1 = new List<Table1>();
XmlSerializer serializer = new XmlSerializer(typeof(List<Table1>));
FileStream stream = File.OpenWrite("data.XML");
serializer.Serialize(stream, listtable1);
But there are 3 types of tables in file. What can i do if i still want to use List<>?
Best Regards.