欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

asp.net下DataSet.WriteXml(String)與(Stream)的區(qū)別

 更新時間:2007年04月13日 00:00:00   作者:  
DataSet.WriteXml(String)生成的Xml文件中包含XML 聲明, 而DataSet.WriteXml(Stream)卻不會寫入Xml聲明即<?xml version="1.0" standalone="yes"?>
詳細(xì)情況:
在寫博客園的數(shù)據(jù)備份程序時,本來想通過ds.WriteXml(Response.OutputStream)直接將Xml數(shù)據(jù)發(fā)送到客戶端,可是這樣在客戶端得到的Xml文件中的所有中文全是亂碼,亂碼的Xml文件與正常的Xml文件區(qū)別就是少了一行Xml聲明。然后, 我改了代碼, 手動寫入Xml聲明, 亂碼問題就解決,代碼如下: 
XmlTextWriter writer = new XmlTextWriter(Response.OutputStream, Response.ContentEncoding);
writer.Formatting = Formatting.Indented;
writer.Indentation = 4;
writer.IndentChar = ' ';
writer.WriteStartDocument();
ds.WriteXml(writer);
writer.Flush();
Response.End();
writer.Close();

相關(guān)文章

最新評論