473,473 Members | 2,061 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Xml deserialization problem..help needed.

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

Mar 28 '07 #1
0 1290

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: TEK | last post by:
There seems to be a bug when deserialization some classes in the .NET framework. If you try to deserialize a class that has a base class that holds a struct with a member that is implementing...
1
by: Tom L | last post by:
Simple deserialization help needed please... I have a packet of xml in a string, and need to get that into a reader./stream of some sort so I can properly use deserialize.. here's my...
2
by: Snowman | last post by:
Suppose I have a RootObject which holds a collection of other objects. The other objects have a property (Parent) which refers back to the "parent" collection (b.t.w. my collection is based on...
3
by: Amadelle | last post by:
Hi all and thanks in advance for your help, I am having problems deserializing an object which seems to be serializing just fine. I save the byte array of the serialized object in the database...
3
by: AnkitAsDeveloper [Ankit] | last post by:
Hi i am serializing a 'ref struct' object as follows : private: void Seri( String ^path, Object^ obj ) { FileStream^ fileStrm ; try { //Serialize entire object into Binary stream
3
by: parrot toes | last post by:
Summary: I have been trying to make requests of a web service provided by Axis using a dotnet client with code generated by wsdl.exe and have been getting exceptions when trying to process the...
3
by: John Glover | last post by:
To whoever can help, I've been having a problem with XML deserialization lately. I needed to serialize and deserialze two objects which inherited from Hashtable. Because IDictionary...
3
by: TheSteph | last post by:
Hi, I have a small serializable struct : public struct TestStruct { public string Title; public int Age; public string Name;
0
by: Alex | last post by:
i have kind of an urgent problem with a deserialization. i have all the clasesses generated by xsd.exe from the xsd file. the xml i get and ai have to deserialize is seomthing like this: <?xml...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.