Here's the GetXml method:
public DataSet GetXml()
{
DataSet ds = new DataSet();
SqlConnection con = new SqlConnection(strConn);
con.Open();
SqlCommand sc = new SqlCommand();
sc.Connection = con;
sc.CommandType = CommandType.Text;
sc.CommandText = "dbo.GetCustNames";
SqlDataAdapter myReader = new SqlDataAdapter(sc);
myReader.Fill(ds);
ds.WriteXml(HttpContext.Current.Server.MapPath("NamesXml.xml"));
con.Close();
con = null;
return ds;
}
myDAL = new DALClass();
string NamesDs = myDAL.GetXml(); //returns xml resultset
NamesDs = "<?xml version=\"1.0\" standalone=\"yes\"?>" + NamesDs;
NamesDs = NamesDs.Replace("\\", string.Empty);
XmlDocument doc = new XmlDocument();
doc.LoadXml(NamesDs);
XmlTextWriter writer = new XmlTextWriter("NamesXml.xml", null);
writer.Formatting = Formatting.Indented;
doc.Save(writer);