cmdText = "SELECT * from tbl_nation for XML RAW , ROOT ('table'), ELEMENTS XSINIL";
string tempFilePath = "c:\\temptable.xml";
TextWriter textWrite = new StreamWriter(tempFilePath);
SqlCommand command = new SqlCommand(cmdText, connection);
SqlDataReader sqlReader= command.ExecuteReader();
if (sqlReader != null)
{
while (sqlReader.Read())
{
textWrite.Write(sqlReader.GetValue(0).ToString());
}
sqlReader.Close();
textWrite.Close();
}
string tempFilePath = "c:\\temptable.xml";
TextWriter textWrite = new StreamWriter(tempFilePath);
SqlCommand command = new SqlCommand(cmdText, connection);
SqlDataReader sqlReader= command.ExecuteReader();
if (sqlReader != null)
{
while (sqlReader.Read())
{
textWrite.Write(sqlReader.GetValue(0).ToString());
}
sqlReader.Close();
textWrite.Close();
}
this is very easy way to create xml file.
ReplyDeletePhp Developer India
Thanks!! for your comment Ankit :-)
Delete