WriteXML mode and schema

  • Thread starter Thread starter Earl
  • Start date Start date
E

Earl

If I use a manually created dataset (for the CompactFramework) and try to
write it out as XML using the following syntax, I get a build error saying
that my file name "Value of type String cannot be converted to
System.XML.XMLWriter:

ds.WriteXml(strPathToXML, XmlWriteMode.WriteSchema)

But if I code it without the WriteMode, I get no build error. I guess it
goes without saying that a non-strongly typed dataset does not know the
schema, so is that the only reason I cannot generate a schema?
 
There has to be a schema to write. Does your XML have an XSD reference in it
and is that schema both accessible and valid ?
 
Thanks for the thoughts guys, but no datagrid was being used in the project.
What I actually ended up doing was this (it was for a CF project):

Wrote the XML to one file
Wrote the Schema to another file

(To read it in)
Created a dataset
Created two streamwriters
Created two XMLReaders
Streamed the Schema to the XMLReader object
Streamed the XML to the other XMLReader object
Used dataset ReadXMLSchema to load the Schema
Used dataset ReadXML to load the XML

Note that CF does not allow Merge, nor does it allow strongly typed
datasets. If there was a better or simpler solution, I've yet to find it.
Strangely, I didn't find that solution in the 50 or so books I have on .Net
either (including the ones from Microsoft Press). Apparently many of the
authors were as lost as I was when originally looking at that problem.
 
Back
Top