A DataSet or DataTable is represented as XML, so it can be transformed into an XmlDocument.This is a quick way to transform.
1.) Populate a DataTable:
DataTable dt = GetDetailsFromDatabase();
2.) Use XmlWriter to write the DataTable Xml to a XmlDocument:
XmlDocument doc = new XmlDocument();
using (XmlWriter xw = doc.CreateNavigator().AppendChild())
{
xw.WriteStartDocument(true);
dt.WriteXml(xw);
}
3.) Now the XmlDocument can be used as is or saved:
doc.Save("test.xml");