this is helpful for conversion:
SqlCommand cmd = default(SqlCommand); SqlDataAdapter DScmdXML = default(SqlDataAdapter);
DataSet DS = new DataSet();
string sql = null;
int i = 0;
int j = 0;
string strPCode = "";
System.Array arrpcode = default(System.Array);
System.IO.StreamWriter xmlSW = default(System.IO.StreamWriter);
for (i = 0; i <= ListBox1.Items.Count - 1; i++) {
if (ListBox1.Items(i).Selected) {
if (string.IsNullOrEmpty(strPCode)) {
strPCode = ListBox1.Items(i).Text;
}
else {
strPCode = strPCode + "," + ListBox1.Items(i).Text;
}
}
}
arrpcode = strPCode.ToString.Split(",");
for (j = 0; j <= arrpcode.Length - 1; j++) {
try {
switch (Strings.UCase(arrpcode(j))) {
case "CATEGORY":
sql = "Select Categoryid, Categoryname from Category ";
cmd = new SqlCommand(sql, connect);
DScmdXML = new SqlDataAdapter(cmd);
DScmdXML.Fill(DS, "Product");
Response.Write("<font face=verdana size=1>" + "Successfully Converted Table " + arrpcode(j) + " to Product.xml" + "</font>");
Response.Flush();
DS.WriteXml("Product.xml", XmlWriteMode.WriteSchema);
System.IO.StreamWriter xmlSW2 = new System.IO.StreamWriter("Category.xml");
DS.WriteXml(xmlSW2, XmlWriteMode.WriteSchema);
xmlSW2.Flush();
xmlSW2.Close();
break;
}
}
catch (Exception ex) {
Response.Write(ex.Message);
}
}
if this Helps you Please Comment On this