Topaz
Topaz 's Blog

Topaz 's Blog

两种将dataset写入到xml的方法

Photo by Shahadat Rahman on Unsplash

两种将dataset写入到xml的方法

Topaz
·Nov 28, 2010·

1 min read

1. //mydsClone.WriteXml(MapPath("/Home/data.xml"));   
2.XmlWriter xtw = new XmlTextWriter(Server.MapPath("/Home/data.xml"), 
    //生成XML
Encoding.GetEncoding("utf-8"));
//设置encoding类型为:utf-8 
xtw.WriteRaw("<?xml version=\\"1.0\\" encoding=\\"utf-8\\"?>");  mydsClone.WriteXml(xtw);
xtw.Close();

两种将dataset写入到xml的方法. 第二种方式可按指定的字符集格式存储!

 
Share this