Buggy DataSet.ReadXml() when reading from an XmlReader?

G

Guest

There seems to be a bug with the DataSet.ReadXml() method.
These are the conditions for failing:
1 - I create a DataSet and a DataTable
2 - I set the namespace of the DataSet (because my xml has a namespace set)
3 - I set the types of the columns of the DataTable (therefore setting a schema in the DataSet)
4 - I create an XMLReader
5 - I invoke ds.ReadXML(xmlReader)
When I execute I get the exception:
Exception details: System.FormatException: The string was not recognized as a valid Boolean value.
at System.Xml.XmlConvert.ToBoolean(String s)
at System.Data.XmlDataLoader.LoadData(DataRow& row, DataTable parentTable, Boolean[] foundColumns)
at System.Data.XmlDataLoader.LoadData(DataTable parentTable)
at System.Data.XmlDataLoader.LoadData(XmlReader reader)
at System.Data.DataSet.ReadXml(XmlReader reader, XmlReadMode mode, Boolean denyResolving)
at System.Data.DataSet.ReadXml(XmlReader reader)

!!!The strange thing is that all columns are strings, and none is a boolean!!!
I notice that this happens when one of the elements in the XML is empty (or contaning white spaces).

I know that this error does not occur if one of the following is true:
-Instead of using a XMLReader I use a StringReader when invoking ds.ReadXml
-I use XmlReadMode.InferSchema when invoking ds.ReadXml


----------------------------
This problem was detected when trying to solve another one, that maybe I'm solving in the wrong way.
I have a XPathNavigator from which I want to create a DataSet.
After some googling I found a class from Aaron Skonnard that is an XMLReader, based on an XPathNavigator, and that's what I'm using.
see http://www.develop.com/technology/resourcedetail.aspx?id=a45534a4-5e93-4e32-94fe-f1e1762aa7bb
Is there a simpler way to solve this second issue?

Thank you!
Paulo Santos
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top