Convert DataSet and DataTable to Xml String helper functions

I created 2 helper functions(can be modified as extensions in .Net Framework 3.5) to output/trace content of DataSet  or DataTable
public static string ToStringAsXml(DataSet ds)

{

 StringWriter sw = new StringWriter();
ds.WriteXml(sw, XmlWriteMode.IgnoreSchema);

string s = sw.ToString();

return s;

}
 

public static string ToStringAsXml(DataTable dt)
{
 StringWriter sw = new StringWriter();
dt.WriteXml(sw, XmlWriteMode.IgnoreSchema);
string s = sw.ToString();
return s;

}

Advertisements