How to show Webservice response as XML in ASP.Net

Last Reply on Jun 03, 2014 11:57 PM By Mudassar

Posted on Jun 03, 2014 11:56 PM

I am using following webmethod

 

[WebMethod]
    public DataSet GetData()
    {
        List<City> city = new List<City>();
        DataSet ds = new DataSet();
        
        string cityname = string.Empty;
        DBManager obj = new DBManager();
        string query1 = "select vehicle_model_name, sitting_capacity, auto_service_id, city_name from auto_service_details, auto_vehicle_model, auto_city where auto_service_details.auto_vehicle_model_id= auto_vehicle_model.auto_vehicle_model_id and auto_city.auto_city_id = auto_service_details.from_loc_city";
        ds = obj.getDataSet(query1);

        return ds;
    }

Creating proxy of web services and call webmethod as follows

 

DataSet ds = proxy.GetData();

Now i need to show this DS in XML format at client side i am usgin following code

 

protected void btnXml_Click(object sender, EventArgs e)
        {
            Response.Buffer = true;
            Response.Clear();
            Response.Charset = "";
            Response.Cache.SetCacheability(HttpCacheability.NoCache);
            Response.ContentType = "application/xml";
            DataSet ds = proxy.GetData();
            Response.Write(ds);
            Response.Flush();
            Response.End();
        }

But it give error like

Error - xml parsing error syntax error line number 1 column 1 in asp.net

Help me for resolve this error & show my OP in XML format. Thanks.

You are viewing reply posted by: Mudassar on Jun 03, 2014 11:57 PM.