How to write the data from database into an XML file?

The DataSet.WriteXml method writes XML data, and optionally the schema, from the DataSet. Specified System.IO.Stream, TextWriter, XmlWriter and XmlWriteMode can be used to write files. To write the schema, set the value for the mode parameter to WriteSchema. Read the data into a dataset from the database. Also make sure you have write and modify rights to the place where the file is being written.

C# example code:

1
2
//Fill the DataSet
ds.WriteXml(Server.MapPath ("products.xml" ) );
Share Article/Example:
  • DotNetKicks
  • DZone
  • StumbleUpon
  • Print
  • Add to favorites
  • Digg
  • del.icio.us
  • Twitter
  • Facebook
  • LinkedIn
  • Posterous
  • Slashdot

 

 
eXTReMe Tracker