我有一个 Web 服务方法,我转换为 xml 以查看我的 xml 转换器方法的 asp 页面:
SqlDataAdapter MyDataAdapter;
MyDataAdapter = new SqlDataAdapter(com.CommandText, SqlConnection);
DataSet dsCategories = new DataSet();
MyDataAdapter.SelectCommand.CommandTimeout = 1000;
MyDataAdapter.Fill(dsCategories, "Category");
dsCategories.WriteXml(Server.MapPath("Category.xml"));
System.IO.StringWriter writer = new System.IO.StringWriter();
dsCategories.WriteXml(writer, XmlWriteMode.WriteSchema);
string xmlFromDataTable = writer.ToString();
response.Write(xmlFromDataTable);
response.ContentType = "text/xml; charset=utf-16";
错误是
在第 1846 行第 19 列:XML 声明只允许在文档的开头
XML 没有 XML 声明标头。我该如何解决?