I was given an XML file that I needed to read in my code as a DataSet (as a background, the file was created by creating a DataSet in C # and calling dataSet.WriteXml(file, XmlWriteMode.IgnoreSchema) , but it was done by someone else )
The .xml file has the following form:
<?xml version="1.0" standalone="yes"?> <NewDataSet> <Foo> <Bar>abcd</Bar> <Foo>efg</Foo> </Foo> <Foo> <Bar>hijk</Bar> <Foo>lmn</Foo> </Foo> </NewDataSet>
Using C # and .NET 2.0, I read the file using the following code:
DataSet ds = new DataSet(); ds.ReadXml(file);
Using a breakpoint, after that line ds.Tables[0] looked like this (using a dash instead of underscores, which I could not format correctly):
Bar Foo-Id Foo-Id-0 abcd 0 null null 1 0 hijk 2 null null 3 2
I found a workaround (I know there are a lot of them) and was able to successfully read in .xml, but I would like to understand why ds.ReadXml(file) is executed this way, so I can avoid the issue in the future. Thanks.
Timothy carter
source share