Posted By: W3bbo | Nov 27th, 2008 @ 6:30 AM
page 1 of 1
Comments: 3 | Views: 624
W3bbo
W3bbo
The Master of Baiters
I've written an XML Schema (*.xsd) file by hand to define an XML file format I'm going to use to store some structured data in. After hearing good things about Typed DataSets working with XML files I used the xsd.exe program to create a DataSet from my XSD.

The thing is... it doesn't seem to work at all.

I've got a regular DataSet and my typed DataSet ("MyDataSet") , both reading data from the same XML file.

...yet it doesn't seem to work:

            DataSet ds = new DataSet();
            ds.ReadXml      ( packageExamplePath );
           
            System.Console.WriteLine( ds.Tables["extra"].Rows.Count ); // prints 19
           
            MyDataSet st = new MyDataSet();
            st.ReadXml( packageExamplePath );
           
            System.Console.WriteLine( st.Tables["extra"].Rows.Count ); // prints 0

Am I missing something important? Do I need to include a reference to the XML schema namespace in the source data XML document or something? I've read MSDN but couldn't find anything relevant.
jh71283
jh71283
Throw new System.Beverage. OutOfCoffeeException​()
For the typed dataset to read the xml, The root node must match the name of your dataset.

I assume your dataset starts with <DataSet> whereas it should be <MyDataSet> for the typed one to read it.

NB. It's case sensitive, too.
jh71283
jh71283
Throw new System.Beverage. OutOfCoffeeException​()
try manually putting some records in, and then call GetXML so you can compare the XML you give to the XML it expects.

page 1 of 1
Comments: 3 | Views: 624
Microsoft Communities