Xml deserialization problem

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
Hello,
Ive got a problem deserializing an Xml file. I am trying to deserialize a crudely formed Xml document through a C# IXmlSerializable class.<br/>

My predecessor wrote a XLAM that takes an Excel worksheet and converts it into crudely formed Xml. In and of itself, no problem, I can write the interface members, no problem.
Each of the elements in the document have unicode content: its a translations from English to/from other languages. Code goes something like this:
<pre class="prettyprint public void ReadXml(XmlReader reader)
{
//I verify Im on the expected node, read some attribute, okay so far...
reader.MoveToContent();
//Debugging reveals that the reader is sitting on the node as I expect.
var translatedText = reader.ReadElementContentAsString();
//Now reader shows a whitespace n
}[/code]
How the next reader spot could be whitespace, I dont know. When I try and do anything like ReadEndElement() to get to the next one, I get XmlException Element is an invalid XmlNodeType. Line 4, position 2.
Ive tried adding "utf-8" or "utf-16" encoding header to the text I am deserializing to no avail.
Any ideas?
Regards,
Michael


View the full article
 
Back
Top