一、xml與dataset的相互轉換的類
usingview codesystem;
using
system.collections.generic;
using
system.text;
using
system.data;
using
system.io;
using
system.xml;
namespace
xmldesign
catch
(system.exception ex)
finally
}//將xml檔案轉換為dataset
public
static dataset convertxmlfiletodataset(string
xmlfile)
catch
(system.exception ex)
finally
}//將dataset轉換為xml物件字串
public
static
string
convertdatasettoxml(dataset xmlds)
catch
(system.exception ex)
finally
}//將dataset轉換為xml檔案
public
static
void convertdatasettoxmlfile(dataset xmlds,string
xmlfile)
catch
( system.exception ex )
finally}}
}
二、 該方法的使用示例
usingview codesystem;
using
system.collections.generic;
using
system.text;
using
system.xml;
using
system.data;
namespace
xmldesign
\\",包含個表",
ds2.datasetname, ds2.tables.count);
foreach (datatable dt in
ds2.tables)
;#endregion 轉換乙個dataset為乙個xml檔案
#region 轉換乙個dataset為乙個xml檔案xmldatasetconvert.convertdatasettoxmlfile(ds2,
"c:\\\\adadsda1。xml");
#endregion
console.readline();
}private
static
void printtablename(string
tablename)}}
XML與DataSet的相互轉換
一 xml 與 dataset 的關係如下圖所示 二 dataset 物件的常用方法如下 a.使用readxml 方法 從檔案或流中載入xml 資料,填充dataset 物件。dataset 物件.readxml 檔案路徑字串 stream 物件,xmlreadmode 列舉值 可以省略 b.使用w...
XML與DataSet的相互轉換
xmldatasetconvert 該類提供了四種方法 1 將xml物件內容字串轉換為dataset 2 將xml檔案轉換為dataset 3 將dataset轉換為xml物件字串 4 將dataset轉換為xml檔案 xmldatasetconvert.cs using system using ...
XML與DataSet的相互轉換
xmldatasetconvert 該類提供了四種方法 1 將xml物件內容字串轉換為dataset 2 將xml檔案轉換為dataset 3 將dataset轉換為xml物件字串 4 將dataset轉換為xml檔案 1 2 3 using system 4 using system.collec...