Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
One dataset. Two XML files
Message
From
11/02/2006 01:05:36
 
General information
Forum:
ASP.NET
Category:
ADO.NET
Miscellaneous
Thread ID:
01095548
Message ID:
01095611
Views:
11
I've tried both XmlReadMode.InferSchema and XmlReadMode.ReadSchema. They work in slightly different manners, but they still should do what you want. InferSchema will add columns if they don't already exist in your DataSet, ReadSchema won't add the extra columns. Auto should work the same as ReadSchema, but if it wasn't working with Auto I bet you didn't have the tables names in the XML corresponding to the table names in your DataSet.

Why did you say you're having second thoughts about InferSchema?

~~Bonnie



>Well it appears that XmlReadMode.InferSchema does what I want the ReadCml() method to do, but after reading about XmlReadMode.InferSchema I am having 2nd thoughts.
>
>Has anoyone else in here done something similar to what I want to do?
>
>Einar
>
>>Here is what I want to do:
>>I have created a typed dataset that has two tables, lets call the tables Table1 and Table2. I receive two XML files, the first XML file (XmlFile1) contains the data for Table1 and the 2nd XML file (XmlFile2) contains data for Table2.
>>
>>Now I want to read the data from XmlFile1 and XmlFile2 into my dataset using the ReadXml() method of my dataset. Something like this:
>>
>>myTypedDataSet ds = new myTypedDataSet();
>>ds.ReadXml(@"C:\somewhere\XmlFile1.xml");
>>ds.ReadXml(@"C:\somewhere\XmlFile2.xml");
>>
>>
>>Now this does not work as I would expect (obviously otherwise I would have posted this message<s>). I want the first ReadXml() to fill ds.Table1 and the 2nd ReadXml() to fill ds.Table2, but neither ds.Table1 nor ds.Table2 has any data in it.
>>
>>I wouldn't be surprised if it has something with XmlReadMode (can be passed to ReadXml()), but I tried to use IgnoreSchema without any luck and I also tried Auto.
>>
>>I am doing this as an effort to make the code better. currently I have two typed datasets ds1 and ds2 which contains Table1 and Table2 respectively. My current code that looks a little like this works great:
>>
>>myTypedDataSet1 ds1 = new myTypedDataSet1();
>>ds1.ReadXml(@"C:\somewhere\XmlFile1.xml", XmlReadMode.IgnoreSchema);
>>myTypedDataSet2 ds2 = new myTypedDataSet2();
>>ds2.ReadXml(@"C:\somewhere\XmlFile2.xml", XmlReadMode.IgnoreSchema);
>>
>>
>>I could swear I have done something like this before (but that was in 1.1) and I can't grasp why it doesn't work now.
>>
>>Any thoughts?
>>
>>Einar
Bonnie Berent DeWitt
NET/C# MVP since 2003

http://geek-goddess-bonnie.blogspot.com
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform