Click here to Skip to main content
15,884,353 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
I need to do a project which will return a custom XML document. I need to populate the datas which i have stored in the table and returns an XML Document with all the datas.

If you have any code on this, please mail me across to my mail id - [Email- Removed]
Posted
Updated 24-Apr-11 15:35pm
v2
Comments
HimanshuJoshi 24-Apr-11 21:34pm    
What have you tried? No one will provide source code for you. Also don't post your e-mail address, you will get notified if someone answers you by codeproject itself.
Sandeep Mewara 25-Apr-11 0:36am    
No effort.

1 solution

I don't know where you stored your table. But one thing you should do that, create webservice method that return a Dataset. After you create the webservice, then consume it you application. The point that you need to have an XML output. To get this XML call the DataSet.WriteXML(string fileName) method.

[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
public class WebService : System.Web.Services.WebService
{
    public WebService()
    {
        //Uncomment the following line if using designed components 
        //InitializeComponent(); 
    }
    [WebMethod]
    public DataSet GetData()
    {
         DataSet dataSet = new DataSet();
        using (SqlConnection connection = new SqlConnection("connectionString"))
        {
            connection.Open();
            using (SqlCommand command = new SqlCommand("SQL Statement",connection))
            {
                SqlDataAdapter adapter = new SqlDataAdapter(command);
                adapter.Fill(dataSet);
            }
        }       
        return dataSet;
    }
}


Web service consumer application say Asp.Net

protected void Page_Load(object sender, EventArgs e)
{
   WebService ws = new WebService();
   DataSet dataSet= ws.GetData();
   dataSet.WriteXml("c:\\exportToXML.xml");
}


I hope this will help you.
 
Share this answer
 
Comments
Sandeep Mewara 25-Apr-11 0:35am    
My 5!
Wonde Tadesse 6-Dec-11 10:21am    
Thanks Sandeep.

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