Using below example we can create XML schema for dataset or data table.
ds.GetXmlSchema() is the important function to do this activity
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace convert_datatable_to_xml
{
class Program
{
static void Main(string[] args)
{
//creating datatable
DataTable dt = new DataTable("Employ");
//adding columns to datatable
dt.Columns.Add("id");
dt.Columns.Add("name");
//adding rows to datatable
dt.Rows.Add("1", "ranga");
dt.Rows.Add("2", "rajesh");
//creating dataset
DataSet ds = new DataSet("Employ_Details");
//adding datatable to dataset
ds.Tables.Add(dt);
//showing dataset value into XMLschema format.
Console.WriteLine(ds.GetXmlSchema());
Console.Read();
}
}
}
If you have any queries or suggestions, please feel free to ask in the comments section.
Post a Comment
Please give your valuable feedback on this post. You can submit any ASP.NET article here. We will post that article in this website by your name.