用Dataset的GetXml方法:private static void DemonstrateGetXml()
{
// Create a DataSet with one table containing two columns and 10 rows.
DataSet ds = new DataSet("myDataSet");
DataTable t = ds.Tables.Add("Items");
t.Columns.Add("id", typeof(int));
t.Columns.Add("Item", typeof(string)); // Add ten rows.
DataRow r;
for(int i = 0; i <10;i++)
{
r = t.NewRow();
r["id"]= i;
r["Item"]= "Item" + i;
t.Rows.Add(r);
} // Display the DataSet contents as XML.
Console.WriteLine( ds.GetXml() );
}
{
// Create a DataSet with one table containing two columns and 10 rows.
DataSet ds = new DataSet("myDataSet");
DataTable t = ds.Tables.Add("Items");
t.Columns.Add("id", typeof(int));
t.Columns.Add("Item", typeof(string)); // Add ten rows.
DataRow r;
for(int i = 0; i <10;i++)
{
r = t.NewRow();
r["id"]= i;
r["Item"]= "Item" + i;
t.Rows.Add(r);
} // Display the DataSet contents as XML.
Console.WriteLine( ds.GetXml() );
}
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货