Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by (output started at /home/content/f/e/r/ferasferas1/html/scriptslibrary/libraries/joomla/database/database.php:2) in /home/content/f/e/r/ferasferas1/html/scriptslibrary/libraries/joomla/session/session.php on line 423

Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /home/content/f/e/r/ferasferas1/html/scriptslibrary/libraries/joomla/database/database.php:2) in /home/content/f/e/r/ferasferas1/html/scriptslibrary/libraries/joomla/session/session.php on line 423

Warning: Cannot modify header information - headers already sent by (output started at /home/content/f/e/r/ferasferas1/html/scriptslibrary/libraries/joomla/database/database.php:2) in /home/content/f/e/r/ferasferas1/html/scriptslibrary/libraries/joomla/session/session.php on line 426

Warning: Cannot modify header information - headers already sent by (output started at /home/content/f/e/r/ferasferas1/html/scriptslibrary/libraries/joomla/database/database.php:2) in /home/content/f/e/r/ferasferas1/html/scriptslibrary/templates/ja_purity/ja_templatetools.php on line 49
Convert DataSet to formatted XML string - The Scripts Library Community

Free Programming Tutorials & Source Code

 
  • Increase font size
  • Default font size
  • Decrease font size
Home C# Convert DataSet to formatted XML string

Convert DataSet to formatted XML string

E-mail
(0 votes, average: 0 out of 5)
In the dataset class, you can use the function GetXml() to return an XML output, but it’s not going to be formatted. The code below converts a dataset to formatted XML output. First, you need to add the IO namespace:
System.IO;
 
DataSet myDataSet;// DataSet to convert
//Use memory stearm to write your dataset onto it:
MemoryStream myMemoryStream = new MemoryStream();
myDataSet.WriteXml(myMemoryStream);

//Use StreamReader to read from the memory stream

StreamReader myStreamReader = new StreamReader(myMemoryStream, System.Text.Encoding.UTF8);
myMemoryStream.Position = 0; // start from position 0
String strOutput = myStreamReader.ReadToEnd(); // read to the end of the file
myStreamReader.Close(); // close stream reader
myMemoryStream.Close();// close momery stream