
Using C# : I want to convert this table into XML. Please ignore
public static string ToXml(this DataTable table, int metaIndex = 0)
{
XDocument xdoc = new XDocument(
new XElement(table.TableName,
from column in table.Columns.Cast()
where column != table.Columns[metaIndex]
select new XElement(column.ColumnName,
from row in table.AsEnumerable()
select new XElement(row.Field(metaIndex), row[column])
)
)
);
return xdoc.ToString();
}
This worked great for me. Thanks stackoverflow.