您的位置:首页 > 其它

导出数据到xml(自动下载)

2012-03-12 11:25 183 查看
手动拼写xml字符串

string title = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n";

string root = "<Batch>\n";

string end = "</Batch>\n";

----------------------

string str = Export2Xml(list);

byte[] by = System.Text.Encoding.Default.GetBytes(str);

this.Response.OutputStream.Write(by,0,Convert.ToInt32(by.Length));

Response.Charset = "gb2312";

Response.AppendHeader("Content-Disposition", "attachment;filename=us_export.xml");

Response.ContentType = "text/xml";

Response.ContentEncoding = System.Text.Encoding.GetEncoding("gb2312");

System.IO.StringWriter tw = new System.IO.StringWriter();

System.Web.UI.HtmlTextWriter hw = new System.Web.UI.HtmlTextWriter (tw);

Response.Write(tw.ToString());

tw.Close();

hw.Close();

Response.End();

输出到前台。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: