DataSet To XmlDocument
public static XmlDocument BuildXml(DataSet ds)
{
XmlDocument doc = new XmlDocument();
MemoryStream mStrm = new MemoryStream();
StreamReader sRead = new StreamReader(mStrm);
// 调用WriteXml方法把DataSet中的数据输出
//不包含架构
ds.WriteXml(mStrm, XmlWriteMode.IgnoreSchema);
//包含架构
//ds.WriteXml(mStrm, XmlWriteMode.WriteSchema);
//ds.WriteXml(mStrm, XmlWriteMode.DiffGram);
// 从数据流的开始位置进行搜索
mStrm.Seek(0, SeekOrigin.Begin);
// 将数据流加载到XmlDocument
doc.Load(sRead);
return doc;
}
遇见了就不要错过