Question

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

Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top