我试过的方法有问题, 问题是:将DataTable转换为XML字符串后,在XML字符串中为什么不存在DataTable 中列值为空的节点。
static string SerializeDataTableXml(DataTable dt)
{
StringBuilder sb = new StringBuilder();
XmlWriter writer = XmlWriter.Create(sb);
XmlSerializer serializer = new XmlSerializer(typeof(DataTable));
serializer.Serialize(writer, dt);
writer.Close();
return sb.ToString();
}
:将DataTable转换为XML字符串后
如何转换的?net framework提供的方法?
net framework有直接可供调用的方法吗?
我用的是
DataTable dt = obj.Value as DataTable; System.IO.TextWriter tw = new System.IO.StringWriter(); dt.WriteXml(tw);
@aehyok: 试试这个看XmlSerializer