RE: Xml deserialization problem..help needed.
- From: Manish Bafna <ManishBafna@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Tue, 27 Mar 2007 16:17:10 -0700
Hi,
I think it is not special character that is causing your problem.Actually
the XML which you are receiving is malformed.Search in below link for
"System.Xml.XmlException: This is an unexpected token. Expected ‘EndElement’.
" and you will come to kmow more about this error.
http://media.techtarget.com/digitalguide/images/Misc/professionalVB_ch12.pdf.
Hope this helps
--
If my answer helped you,then please do press Yes below.
Thanks and Regards.
Manish Bafna.
MCP and MCTS.
"PierceBrosnan" wrote:
I am using C#(Vs.Net 2003).
The error I am getting is...
System.Xml.XmlException: This is an unexpected token. The expected token is
'EndElement'
I have come to understand that this error is being caused by a character or
set of characters...in the value of an xml element.
I am receiving the xml data basically via a webservice(I have no control
over this data).
I am deserializing the xml data into a c# class I have created. The
deserialization of the data was working great...until I received "bad" xml
data. I think the character is '&' or ' " '. I could be wrong but it is a
character or set of.....that is causing the error.
The code i am using is....
object obj = new object();
XmlSerializer xs = new XmlSerializer(type);
MemoryStream memoryStream = new
MemoryStream(StringToUTF8ByteArray(xmlstring));
XmlTextWriter xmlTextWriter = new XmlTextWriter(memoryStream, Encoding.UTF8);
obj = xs.Deserialize(memoryStream); <--- The error occurs at this point...
I have also tried..
System.Xml.XmlDocument xml = new XmlDocument();
xml.LoadXml(xmlstring);<--- error at this point also...
Now!...I have been searching for a while...i gave up on it..and now i am
back on the search. I ended up here and was hoping that solutions I came
across would help...unfortunately...nothing. If ANYONE can help me with this
situation..i would be "Oooo So Greatful".
Soln I have tried: - Changing the class field types from string to
xmlelement that then referencing the data by the InnerText Property.
- I also tried a "formatXMLString" method I came across..and all that
happened was that the exception error was not occuring at the same point.
Exception error:There is an error in XML document (28, 132);
All I want to do is take a string of xmldata and deserialize it into a class.
I realise that when I output the string of xmldata onto a webpage it comes
up..formatted properly.
Thanks
- Follow-Ups:
- RE: Xml deserialization problem..help needed.
- From: PierceBrosnan
- RE: Xml deserialization problem..help needed.
- Prev by Date: Re: HTML-page clicked in Google don't get me to the website
- Next by Date: RE: Xml deserialization problem..help needed.
- Previous by thread: Why does my web services client generate SOAP with blank namespace?
- Next by thread: RE: Xml deserialization problem..help needed.
- Index(es):
Relevant Pages
|