Click here to Skip to main content
15,886,617 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

I want to generate a XML file from SQL table.

below is my code

C#
protected void Button1_Click(object sender, EventArgs e)

        {

            SqlConnection con = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["mssp"].ConnectionString);
            string strSQL = "Select UserId, UserName from UserDetail";
            SqlDataAdapter dt = new SqlDataAdapter(strSQL, con);
            DataSet ds = new DataSet();
            dt.Fill (ds,"UserDetail");
            ds.WriteXml(Server.MapPath("emp_xml_file.xml"));
        }    
    }


It is generating the XML file like this

C#
<NewDataSet>
<UserDetail>
<UserID>101</UserID>
<UserName>AAA</UserName>
</UserDetail>
<UserDetail>
<UserID>102</UserID>
<UserName>BBB</UserName>
</UserDetail>
</NewDataSet>


I need the XML file like this

XML
<chart caption="sample" showlegent="1" decimalprecision="0">
<category>
<details id="101" name="AAA" />
<details id="102" name="BBB" />
</category>
</chart>

Please help. Thanks in advance
Posted
Updated 12-Sep-13 18:24pm
v2

1 solution

 
Share this answer
 

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