Reputation: 23
i want to convert XML data into data table.my XML file contains many nested tags.how can i display those data in a data table using C#
<school>
<staff>
<staffname>raj</staffname>
<staffname>rani</staffname>
</staff>
<students>
<firstclass>
<name>nani</name>
<rollno>1</rollno>
</firstclass>
<secondclass>
<name>rani</name>
<rollno>1</rollno>
</secondclass>
</students>
</school>
this is the sample file .Now i want to display this data in a Data Table using c#.
can any one help me to solve this issue
Upvotes: 0
Views: 1702
Reputation: 1084
You can use the following code
DataSet dsTest = new DataSet();
dsTest.ReadXml(filepath, XmlReadMode.Auto);
DataTable dt = dsTest.Tables[0];
Upvotes: 2