DataSet.WriteXml to string

pistacchio picture pistacchio · Jun 8, 2009 · Viewed 53.4k times · Source

I'm tring to get a string from a DataSet without using GetXml. I'm using WriteXml, instead. How to use it to get a string? Thanks

Answer

Mehrdad Afshari picture Mehrdad Afshari · Jun 8, 2009
StringWriter sw = new StringWriter();
dataSet.WriteXml(sw);
string result = sw.ToString();