473,738 Members | 5,084 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Derialization issues StringReader, XmlNodeReader - bug??

To whom it may concern:

Can anyone explain this behaviour in serialization and deserialization ?

I serialize an object using an XML serializer.
I de-serialize the object from a StringReader and it deserializes correctly
I de-serialize the object from a XmlNodeReader and it deserializes
incorrectly.
The xml code contained in the StringReader and XmlNodeReader is IDENTICLE.

I apologize for the hacked code snippet - it is not production code, just
code to demonstrate.

Looking forward to the feedback,
Brian.

DictionaryEntry entry;
XmlSerializer xs;
StringWriter sw;
StringReader sr;
XmlDocument doc;

entry = new DictionaryEntry ("key", "test");
sw = new StringWriter();
xs = new XmlSerializer( typeof (DictionaryEntr y));
xs.Serialize( sw, entry);

sr = new StringReader(sw .ToString());
entry = (DictionaryEntr y)xs.Deserializ e(sr);

doc = new XmlDocument();
doc.LoadXml(sw. ToString());
entry = (DictionaryEntr y)xs.Deserializ e(new XmlNodeReader(d oc));

Nov 12 '05 #1
0 1267

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

Similar topics

4
3165
by: Vannela | last post by:
I am using stringreader to repeat through each line of a file ,but my string reader is clubbing 4 to 5 lines as single line at few places, what could be the problem? Please send me the suggestions Thank you
4
11399
by: Andy Neilson | last post by:
I've run across a strange behaviour with XmlSerializer that I'm unable to explain. I came across this while trying to use XmlSerializer to deserialize from a the details of a SoapException. This should have worked fine since the class in question was already being serialized and deserialized as part of a Web service interface. What I found was that by deserializing from an XmlNodeReader instead of an XmlTextReader, XML Serialization doesn't work...
1
2591
by: Kris Desmadryl | last post by:
I want to loop all nodes of an xml file, because I want to search the content for a certain search pattern. I did something like this : reader = New XmlNodeReader(doc) While reader.Read() Select Case reader.NodeType Case XmlNodeType.Element Select Case reader.Name Case "al" Dim value As String
4
4701
by: David | last post by:
All I have an XML document as illustrated in the extract below. I am trying to use the XmlNodeReader to extract information from the document. What I am having trouble with is when I read the line of the document I am unable to read the value of the element. Below is an extract of the source code that I am using to read the other parts of the document that I want to extract. Any assistance would be appreciated. Thanks
4
3569
by: Samuel R. Neff | last post by:
I'm deserializing an XML file. If I pass a Stream to the file directly to the deserializer as follows it works fine: o = (New XmlSerializer( GetType( CompensationPackage))).Deserialize(stream) But if I pass an XmlNodeReader to the deserializer it doesn't work:
2
16304
by: Bryan Dickerson | last post by:
StreamReader says it is designed to read a stream of characters StringReader says it is designed to read a string TextReader says it is designed to read a sequential list of characters. I hate to sound like a VB6 grump, but aren't we splitting hairs?? What's the difference? -- TFWBWY...A
2
5650
by: das | last post by:
hello all, might be a dumb one, I have a StringWriter to which I write some text, after doing this I want to read this into a StringReader so that I can manipulate the data ex: while(strRdr.Peek() -1) { // Read data and load into a Physical File - StreamWriter } I know that this can be done easily if the text can be written to
1
1919
by: WalterWalt | last post by:
Below is a part of my xml file returned from a webservice. Instead of converting to a datatable and going through it a record at a time checking if ClientCodeType = "Balloon_Type" and ClientCode = "R" to the OurCode of 3, I want to use the XMLNodeReader to get that result back using MoveTo.. functions. My first of probably many question is how come this XMLNodeReader has no attributes. I can not change the way the webservice returns the...
10
1667
by: jambalapamba | last post by:
I am trying to skip element in xml document where style attribute is VISIBILITY: hidden or DISPLAY: none. In the following example i want to skip the last two elements but when i skip the element with id=”Div1” and next reader.Read() reads “ includeme” but i expected it to read element <a id ="Div2" style="visibility:hidden "> and skip it instead its writing “ includeme” to the console ...
0
8968
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
8787
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
9208
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
8208
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
6750
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4569
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4824
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3279
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
2
2744
muto222
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.