[Mono-list] XmlSerializer Deserialize problem

Kieren Drapala (TSW) kieren@tsw.com.au
Thu, 5 Feb 2004 08:59:15 +1000


Hello,

I am having trouble deserialising XML with a dataset class generated by MS
XSD.exe from a simple schema.

Here is the main part of the code:

XmlSerializer serializer = new XmlSerializer(typeof(GetBillerResponse.OFX));
//GetBillerResponse.OFX was a dataset class generated by MS XSD.exe
System.IO.StringReader xmlSR = new System.IO.StringReader(lcContents); 
// lcContents is a string that contains the XML
GetBillerResponse.OFX po = (GetBillerResponse.OFX)
serializer.Deserialize(xmlSR); // <-- failing here

The Error:
System.Xml.Schema.XmlSchemaException: XmlSchema error: The root element must
be schema
in <0x0024f> System.Xml.Schema.XmlSchema:Read
(System.Xml.XmlReader,System.Xml.Schema.ValidationEventHandler)
in <0x00073> System.Data.XmlSchemaMapper:Read (System.Xml.XmlReader)
in <0x00043> System.Data.DataSet:ReadXmlSchema (System.Xml.XmlReader)
in <0x00042>
System.Data.DataSet:System.Xml.Serialization.IXmlSerializable.ReadXml
(System.Xml.XmlReader)
in <0x00045>
System.Xml.Serialization.XmlSerializationReader:ReadSerializable
(System.Xml.Serialization.IXmlSerializable)
in <0x0016b>
System.Xml.Serialization.XmlSerializationReaderInterpreter:ReadXmlSerializab
leElement (System.Xml.Serialization.XmlTypeMapping,bool)
in <0x00104>
System.Xml.Serialization.XmlSerializationReaderInterpreter:ReadObject
(System.Xml.Serialization.XmlTypeMapping,bool,bool)
in <0x000a2>
System.Xml.Serialization.XmlSerializationReaderInterpreter:ReadObject ()
in <0x00075> System.Xml.Serialization.XmlSerializer:Deserialize
(System.Xml.Serialization.XmlSerializationReader)
in <0x00068> System.Xml.Serialization.XmlSerializer:Deserialize
(System.Xml.XmlReader)
in <0x0003f> System.Xml.Serialization.XmlSerializer:Deserialize
(System.IO.TextReader)


I have read articles about 'Locale' problem etc early last year.

Questions:
1. Is this a simple mistake on my behalf ?

2. I don't really want to do anything with the schema functions at this
stage in my process, how can I not use these (reference to stack trace and
calls to 'Schema' functions)  ?

Please advise, thanks in advance, regards, 

Kieren Drapala
Analyst / Programmer
The System Works Pty Ltd