///
<summary>
///
Gets the xml as string.
///
</summary>
///
<param
name="dt">DataTable
that need to be converted to xml.</param>
///
<returns>XML
as string with schema.</returns>
private
static
string
GetXML(DataTable
dt)
{
if
(string.IsNullOrEmpty(dt.TableName))
{
dt.TableName = "My
DataTable";
}
StringWriter
writer = new
StringWriter();
dt.WriteXml(writer,
XmlWriteMode.WriteSchema,
true);
return
writer.ToString();
}
///
<summary>
///
Gets the DataTable from XML.
///
</summary>
///
<param
name="xmlData">XML
as string.</param>
///
<returns>DataTable
with the schema.</returns>
private
static
DataTable
GetDataTable(string
xmlData)
{
DataTable
dt = new
DataTable("My Data");
try
{
StringReader
stringReader = new
StringReader(xmlData);
dt.ReadXml(stringReader);
}
catch
(Exception
ex)
{
throw
new
Exception(ex.Message);
}
return
dt;
}
No comments:
Post a Comment