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());
精彩评论