开发者

Specify the encoding in xml file

开发者_高级运维

i have an Dataset where i am converting it into an xml file, now i need to specify encoding="UTF-8" in xml file, i am using an vs2003, pls let me know the syntax how to do it.

my code

SqlConnection con = new SqlConnection(dbconn);
            con.Open();
            SqlDataAdapter cmd1 = new SqlDataAdapter("select * from employee", con);
            DataSet ds = new DataSet();
            cmd1.Fill(ds);
            string strFileName = @"E:\Diff2.xml";

            MemoryStream memStream = new MemoryStream();  
            StreamWriter writer = new StreamWriter(memStream, Encoding.Default); 
            ds.WriteXml(writer, XmlWriteMode.WriteSchema);

thanks prince


try this

MemoryStream memStream = new MemoryStream();

StreamWriter writer = new StreamWriter(memStream, Encoding.Default);
ds.WriteXml(writer, XmlWriteMode.WriteSchema);

// Return XML string

return Encoding.Default.GetString(memStream.GetBuffer());
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜