I have a dataset that I read in from a complex xml structure....
here is a basic version of it, for the sake of the question
<cars>
<car>
<carName>Golf</carName>
<engine>
<model></model>
</engine>
<//car>
<car>
<carName>Dodge</carName>
<engine>
<model></model>
</engine>
<//car>
</cars>
Firstly I create the dataset to get the whole document.... (and I read this from file)
DataSet dsCars = new DataSet();
dsConfiguration.ReadXml("allcars.xml"));
Next I want to loop through all car rows.. to do this I use the following code:
foreach(DataRow carDataRow in dsCars.Tables["Car"].Rows)
Now in this loop, I want to inject the car row (AND all its sub content) into a new dataset
So in the foreach loop I have code to
- Create the new dataset
- Create a new datatable = CarList2
- Import the row using : tempTaskTable2.ImportRow(carDataRow);
But when I serialize to file using: tempTaskDS.WriteXml(@"c:\test.xml");
The newly created datatable = Carlist2 is blank and contains no data at all...
What am I doing wrong?