I have a web service method and I convert to xml for viewing asp page my xml converter method:
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";
The error is
on line 1846 at column 19: XML declaration allowed only at the start of the document
The XML does not have the XML Declaration header. How can I fix it?