How do we read XML Schema and Data into a Dataset ?

 Posted by Chvrsri on 1/30/2012 | Category: .NET Framework Interview questions | Views: 7275 | Points: 40

We can read the XML Schema and data into Dataset using --

Dataset.ReadXml command.

example Follows :

DataSet DemoDataSet = new DataSet();

DataTable DemoDataTable = new DataTable("Table Name");
DemoDataTable .Columns.Add("Column Name", typeof(string));
DemoDataSet .Tables.Add(DemoDataTable);

string strXMLData = "<XmlDS><table1><col1>Value1</col1></table1><table1><col1>Value2</col1></table1></XmlDS>";

System.IO.StringReader xmlSR = new System.IO.StringReader(strXMLData);

DemoDataSet .ReadXml(xmlSR, XmlReadMode.IgnoreSchema);

Source: MSDN | Asked In: Many Interviews | Alert Moderator 

Comments or Responses

Login to post response