1)我做一个Dataset.WriteToXml(内存流对象) 2)然后我创建一个XMLDocument对象3)我然后XMLDocument.Load (内存流对象)
我得到了一个“未找到XML根命名空间”异常。
Dataset XML是否不包括所需的命名空间?
谢谢。
发布于 2009-01-22 14:51:55
在尝试将内存流加载到XmlDocument之前,您是否重新定位了内存流?
DataSet ds = new DataSet();
using (SqlConnection connection = new SqlConnection("some connection string"))
using (SqlCommand command = new SqlCommand("select * from mytable", connection))
using (SqlDataAdapter adapter = new SqlDataAdapter(command))
{
adapter.Fill(ds);
}
XmlDocument xml = new XmlDocument();
using (Stream stream = new MemoryStream())
{
ds.WriteXml(stream);
// We must reposition the memory stream before loading the xml
stream.Position = 0;
xml.Load(stream);
}https://stackoverflow.com/questions/469341
复制相似问题