473,791 Members | 2,861 Online
Bytes | Software Development & Data Engineering Community
+ 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.XmlE xception: 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(t ype);

MemoryStream memoryStream = new
MemoryStream(St ringToUTF8ByteA rray(xmlstring) );

XmlTextWriter xmlTextWriter = new XmlTextWriter(m emoryStream, Encoding.UTF8);

obj = xs.Deserialize( memoryStream); <--- The error occurs at this point...

I have also tried..

System.Xml.XmlD ocument xml = new XmlDocument();

xml.LoadXml(xml string);<--- 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...unfortun ately...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 "formatXMLStrin g" 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 1315

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

Similar topics

3
1664
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 the ICollection interface, this causes the deserialization to fail. In my case this is a huge problem, and any suggestion for a workaround would be happily received. A small example of a set of classes that reproduces the problem is included
1
2085
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 deserialization routine (its part of a property as you can tell).. Set(ByVal Value As String) Dim serializer As New XmlSerializer(GetType(Package)) Dim xmlstream As New MemoryStream
2
3825
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 CollectionBase), in similar fashion as the object models of MS Office. I want to serialize this object graph (with RootObject as the xml document element) without Parent property serialized, this may be done by adding XmlIgnoreAttribute on the...
3
9796
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 (when I check the database the field that holds the binary data seems populated), but when I want to deserialize this same byte array the application fails and gives me the following error: Binary stream does not contain a valid BinaryHeader, 0...
3
2069
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
9796
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 response. As a result of seraching news groups I guessed that the SOAP response defines an array element in a way that causes the dotnet deserialization routines to put the content in a generic object array (object) BUT the content is supposed to...
3
5000
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 implementations cannot be serialized, I had to take matters into my own hands by implementing a wrapper over the Hashtable which implemted IXmlSerializable. I called it XmlHashtable. It has, among other convenience methods, a method
3
2221
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
954
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 version="1.0" encoding="UTF-8" standalone="yes"?> <m:incomingEngineMessage xmlns:c="http://www.bvb.ro/xml/ns/arena/gw/ constraints" xmlns:m="http://www.bvb.ro/xml/ns/arena/gw/msg" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <content...
0
9669
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9515
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10426
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10207
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10154
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9993
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9029
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
4109
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 we have to send another system
3
2913
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.