如何用MSSQL直接生成XML文件
发布网友
发布时间:2022-04-19 22:21
我来回答
共1个回答
热心网友
时间:2022-04-10 09:14
List<Area> list = a.GetAllAreaById(id);
//将list集合序列化到流中
MemoryStream stream = new MemoryStream();
XmlSerializer s = new XmlSerializer(typeof(List<Area>));
s.Serialize(stream, list);
//将流转换成字节数组,再解码为字符串
string ss = System.Text.Encoding.UTF8.GetString(stream.ToArray());
XmlDocument dom = new XmlDocument();
dom.LoadXml(ss);
Response.ContentType = "text/xml";
Response.Charset = "utf-8";
HttpContext.Current.Response.Write(dom.OuterXml);