Click here to Skip to main content
15,881,455 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
my XMLDOCUMENT web service return XMLNODE
below is my method

C#
[WebMethod]
[ScriptMethod(ResponseFormat = ResponseFormat.Xml)]
public XmlDocument SearchBySpot(string spot)
{
    XmlDocument doc = new XmlDocument();
    try {
        DataTable result = new DataTable();
        result.TableName = "Location";
        string con = "myconnstring";
        using (SqlConnection connection = new SqlConnection(con))
        {

            SqlCommand cmd = new SqlCommand("GetByspot", connection);
            cmd.CommandType = CommandType.StoredProcedure;
            SqlParameter parameter = new SqlParameter("@spot", spot);
            cmd.Parameters.Add(parameter);
            connection.Open();
            SqlDataAdapter adapter = new SqlDataAdapter(cmd);
            SqlDataReader reader = cmd.ExecuteReader();
            result.Load(reader);



            DataSet ds = new DataSet();
            adapter.Fill(ds, "Location");
            string strXML = ds.GetXml();

            doc.LoadXml(strXML);



            connection.Close();



        }

    }
    catch (Exception ex)
    {

    }
    return doc;
}
Posted
Updated 29-Jul-14 4:27am
v2
Comments
Raje_ 29-Jul-14 10:30am    
What is your question?
ZurdoDev 29-Jul-14 10:31am    
OK? Do you have a question?
breab 29-Jul-14 10:50am    
my question is my webservice should return XMLDOCUMET but it is returning XMLNODE why ......?
ZurdoDev 29-Jul-14 12:57pm    
1. Reply to the comment so that we are notified.
2. It says it is returning an XmlDocument. Why do you think it is only returning an XmlNode?
j snooze 29-Jul-14 13:56pm    
I'm guessing this is your problem here.
http://stackoverflow.com/questions/5558407/webservice-method-return-xmldocument-reference-sees-a-xmlnode

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900