[Mono-list] XmlSerializer Deserialize problem

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


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
in <0x00073> System.Data.XmlSchemaMapper:Read (System.Xml.XmlReader)
in <0x00043> System.Data.DataSet:ReadXmlSchema (System.Xml.XmlReader)
in <0x00042>
in <0x00045>
in <0x0016b>
leElement (System.Xml.Serialization.XmlTypeMapping,bool)
in <0x00104>
in <0x000a2>
System.Xml.Serialization.XmlSerializationReaderInterpreter:ReadObject ()
in <0x00075> System.Xml.Serialization.XmlSerializer:Deserialize
in <0x00068> System.Xml.Serialization.XmlSerializer:Deserialize
in <0x0003f> System.Xml.Serialization.XmlSerializer:Deserialize

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

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