views:

1106

answers:

1

What is the best way to convert an XML document to a .NET 2.0 DataSet. The XML document contains complex structures with parent-child relationships and should be transformed into multiple tables in the DataSet. The DataSet tables should also maintain the relationship among tables. right now, I've to write custom XSLT to do this transformation

+3  A: 

The best (meaning easiest) way, that also includes all the parent/child relationships is...

DataSet myDataSet = new DataSet();

myDataSet.ReadXml("myXmlFile.xml");

Tada!

BTW, if you have the XML in memory (and not in a file), then you can use one of the "ReadXml" overloads to read it from a stream.

Timothy Khouri
Don't forget that you cane use DataTableCollection and myDataSet.Tables(n) to access table data
mmcglynn