如何将DataSet中的数据保存为UTF-8编码的xml 如何将DataSet中的数据保存为UTF-8编码的xml? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 默认的就是UTF8编码的吧如果不是的话,就用这个System.Xml.XmlTextWriter writer = new System.Xml.XmlTextWriter("r:\\1.xml", System.Text.Encoding.UTF-8);yourdataset.WriteXml(writer); 编码与你的网站编码有关吧!写入的话用:dataset.writeXML("文件名") System.Xml.XmlTextWriter writer = new System.Xml.XmlTextWriter( "r:\\1.xml ", System.Text.Encoding.UTF-8); yourdataset.WriteXml(writer); .... xmldoc = new XmlDocument(); //加入XML的声明段落,<?xml version="1.0" encoding="UTF-8"?> XmlDeclaration xmldecl; xmldecl = xmldoc.CreateXmlDeclaration("1.0", "UTF-8", null); xmldoc.AppendChild(xmldecl);... if (ds.Tables[0].Rows.Count > 0) { for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { strXFNo = ds.Tables[0].Rows[i]["XFNo"].ToString(); xmlelem2 = xmldoc.CreateElement("", ds.Tables[0].ToString() + "Schema", ""); xmlelem2.SetAttribute("Operate", "DELETE&INSERT"); xmlelem1.AppendChild(xmlelem2); for (int j = 0; j < ds.Tables[0].Columns.Count; j++) { xmlelem3 = xmldoc.CreateElement("", ds.Tables[0].Columns[j].ToString(), ""); if (ds.Tables[0].Rows[i][j].ToString() != "") { xmlelem3.InnerText = ds.Tables[0].Rows[i][j].ToString(); } xmlelem2.AppendChild(xmlelem3); } } } xmldoc.Save(strPath + ds.Tables[0].ToString() + "_YB.xml"); }... picturebox画出的图形不能直接打开而是要点击一下鼠标才能出现 WPF templatebinding问题 加急,使用at指令接受短信,求大神 有关用C#打印的问题 窗口传值问题 c#回调 可以返回值但出现脚本错误提示,请指教。 怎么得到新记录的ID? sql问题(菜鸟提问) java加密,求个c#对应的加密方法 简体<--->繁体,如何实现? 如何保存窗体中的绘图? 关于UDP通讯的问题
System.Xml.XmlTextWriter writer = new System.Xml.XmlTextWriter("r:\\1.xml", System.Text.Encoding.UTF-8);
yourdataset.WriteXml(writer);
yourdataset.WriteXml(writer);
xmldoc = new XmlDocument();
//加入XML的声明段落,<?xml version="1.0" encoding="UTF-8"?>
XmlDeclaration xmldecl;
xmldecl = xmldoc.CreateXmlDeclaration("1.0", "UTF-8", null);
xmldoc.AppendChild(xmldecl);
...
if (ds.Tables[0].Rows.Count > 0)
{
for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
{
strXFNo = ds.Tables[0].Rows[i]["XFNo"].ToString();
xmlelem2 = xmldoc.CreateElement("", ds.Tables[0].ToString() + "Schema", "");
xmlelem2.SetAttribute("Operate", "DELETE&INSERT");
xmlelem1.AppendChild(xmlelem2);
for (int j = 0; j < ds.Tables[0].Columns.Count; j++)
{
xmlelem3 = xmldoc.CreateElement("", ds.Tables[0].Columns[j].ToString(), "");
if (ds.Tables[0].Rows[i][j].ToString() != "")
{
xmlelem3.InnerText = ds.Tables[0].Rows[i][j].ToString();
}
xmlelem2.AppendChild(xmlelem3);
}
}
}
xmldoc.Save(strPath + ds.Tables[0].ToString() + "_YB.xml");
}
...