.Text源程序博客列表(OPML) 默认xml格式为UTF16的问题修正

.Text源程序博客列表(OPML)  默认xml格式为UTF-16,一打开就出错(看看博客堂的http://blog.joycode.com/Opml.aspx就知道,呵呵),很不爽的说,主要因为XmlTextWriter默认是UTF-16,后来发现一个很简单的方法解决这个问题:

打开OPML.aspx.cs (我用的是0.95版)

   DataTable dt = SqlHelper.ExecuteDataTable(conn,CommandType.StoredProcedure,sql,p);
   Response.ContentType = "text/xml";
   Response.ContentEncoding = System.Text.Encoding.UTF8; //这个是新加上的
   Response.Write(Opml.Write(dt,Request.ApplicationPath));
....

   public static string Write(DataTable dt, string appPath)
   {
...
     XmlTextWriter writer = new XmlTextWriter(sw);
     writer.Formatting = Formatting.Indented;
//     writer.WriteStartDocument(); 这一行注释掉,就OK啦!

  ....

原文地址:https://www.cnblogs.com/dotey/p/5121.html