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
2008-10-27 09:28:44
Don't forget that you cane use DataTableCollection and myDataSet.Tables(n) to access table data
mmcglynn
2009-06-17 20:23:51