xml 有没有头 “<?xml version="1.0" encoding="gb2312"?>”

解决方案 »

  1.   

    没有,因为是用ds.writexml(filestream)生成的文件,也就是.net写的xml文件,我如何可以令.net写xml文件时加上 encoding="gb2312"
      

  2.   

    嗯,我也从数据库返回数据进入过xml得哦,没有遇到过。
      

  3.   

    不知道你的filestream是如何定义的。直接这样如何呢?
    ds.writexml(Server.MapPath("filename.xml"))
      

  4.   

    using System.Xml;XmlTextWriter xtw = new XmlTextWriter(Server.MapPath("Yourfile.xml"), System.Text.Encoding.GetEncoding("GB2312"));
    //xtw.Formatting = Formatting.Indented;
    xtw.WriteStartDocument();YourDataSet.WriteXml(xtw);xtw.WriteEndDocument();
    xtw.Close();