A question on DataSet.ReadXml.

  • Thread starter Thread starter Manuel Vázquez Acosta
  • Start date Start date
M

Manuel Vázquez Acosta

Hi all,

I'm dealing with a buggy-like behaviour when I call ReadXml method of
DataSet.

Here the scene:

I have myCustomDset.xsd and its associated/generated myCustomDset.cs; now my
data is stored in an xml file, say data.xml.

If I try to fill the DataSet without calling ReadXmlScheme, it seems the
DataSet doesn't fill correctly (at all?):

myCustomDset dset = new myCustomDset();
// If I comment or remove the following line, the DataSet doesn't fill
correctly (or at all)
myCustomDset.ReadXmlSchema(strDataFileName);
myCustomDset.ReadXml(strDataFileName);


From the docs:

ReadXml: Reads XML schema and data into the DataSet

Notice it states the schema is also read.


A bug or not a bug? That's my question ;-)

Regards,
Manuel.
 
Hi
Try using something like ds.ReadXml("x", XmlReadMode.ReadSchema) which will
read the schema. If you look at the help for readxmlshema, you will notice
that it mentions that the ReadXmlSchema method is generally invoked before
invoking the ReadXml method.
Thanks
Ibrahim
 
Hum, ok that works; but I'm still concerned about the possible overhead
caused by this step; I wonder: What is the advantage in generating the
myCustomDset class if it still needs to read the Schema? Or reading schema
means to validate whether the given xml represents a valid dataset?

Thanks,
Manuel.
 
Back
Top