C # convert DataTable to XML string public string ConvertDataTableToXml (DataTable dt) {StringBuilder strXml = new StringBuilder (); strXml. appendLine ("<MonitorData>"); for (int I = 0; I <dt. rows. count; I ++) {strXml. appendLine ("<rows>"); for (int j = 0; j <dt. columns. count; j ++) {strXml. appendLine ("<" + dt. columns [j]. columnName + ">" + dt. rows [I] [j] + "</" + dt. columns [j]. columnName + ">");} strXml. appe NdLine ("</rows>");} strXml. appendLine ("</MonitorData>"); return strXml. toString ();} C # converts an XML string to a DataTable private DataTable ConvertXmlToDataTable (string xmlData) {StringReader stream = null; XmlTextReader reader = null; try {DataSet xmlDS = new DataSet (); stream = new StringReader (xmlData); reader = new XmlTextReader (stream); xmlDS. readXml (reader); return xmlDS. tables [0];} catch (Ti On ex) {string strTest = ex. Message; return null;} finally {if (reader! = Null) reader. Close ();}}