Hi,
I need to generate XML from a SQL table.
My xml need to be like this.
="1.0"="utf-8"
<graph caption='Sample xml' xAxisName='Country'
yAxisName='GDP' showNames='1' decimalPrecision='0' formatNumberScale='0'>
<set name='Qatar' value='102768' color='#FF0000' />
<set name='Luxembourg' value='80679' color='#00FF00' />
<set name='Singapore' value='60883' color='#0000FF' />
<set name='Norway' value='55264' color='#00FFFF' />
<set name='Brunei' value='50526' color='#FF00FF' />
<set name='United States' value='49802' color='#FFFF00' />
<set name='UAE' value='48992' color='#FFAAFF' />
<set name='Switzerland' value='45285' color='#CCFFBB' />
<set name='Kuwait' value='43846' color='#00AABB' />
<set name='Austria' value='42477' color='#BBCCFF' />
</graph>
My sql table structure will be like this
Name Value Color
Qatar 102768 #FF0000
Luxembourg 80679 #00FF00
Singapore 60883 #0000FF
Norway 55264 #00FFFF
My code behind will be like this..
protected void Button1_Click(object sender, EventArgs e)
{
SqlConnection con = new SqlConnection("Data Source=.; uid=sa; pwd=wintellect;database=Rohatash;");
string strSQL = "Select name, value, color from Details";
SqlDataAdapter dt = new SqlDataAdapter(strSQL, con);
DataSet ds = new DataSet();
dt.Fill (ds,"Details");
ds.WriteXml(Server.MapPath("Sample_xml_file.xml"));
}
This code is not giving me deisred result.
Please help to get the desired XML output.