C# 创建xml文档. xml文件中有中文字符,无法用浏览器显示

    XmlDocument doc = new XmlDocument();
            XmlDeclaration dec = doc.CreateXmlDeclaration("1.0", "GB2312", null);
            doc.AppendChild(dec);
            //创建一个根节点(一级)
            XmlElement root = doc.CreateElement("First");
            doc.AppendChild(root);

//xml文件包含中文字符,且没有说明xml编码格式时.就无法被xmlDocument对象和IE识别。

   解决方式,在xml文件中添加encoding说明  <?xml version=“1.0” encoding="GBK"?>  即可

原文地址:https://www.cnblogs.com/imihiroblog/p/2518472.html