tags:

views:

1845

answers:

2

Hi, 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

+4  A: 

Write to a StringWriter, and then call ToString on that.

Note that if you want the generated XML declaration to specify UTF-8 instead of UTF-16, you'll need something like my Utf8StringWriter.

Jon Skeet
+5  A: 
StringWriter sw = new StringWriter();
dataSet.WriteXml(sw);
string result = sw.ToString();
Mehrdad Afshari