473,756 Members | 2,558 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Deserializing - Can this be done?

I want to be able to deserialize data contained within a XML file to a data
structure. This I know how to do. However, what I want to be able to do is
the following:
1. Serialize multiple "C# classes" into a single XML file. One at a time.
2. Deserialize each "C# class" from the XML file. One at a time.

Is this possible? I don't see a way to do this. If it isn't possible does
anyone have a suggestion on how to get around a problem I have. I have many
data structures that I need to save to disk and later retrieve when a program
runs. The data structures are contained in nodes of a TreeView list. If I
serialize each structure one-by-one I may have hundreds of XML files. I want
to group certain TreeView node-paths all under a single XML file to have
fewer XML files to manage and thus make things easier. How could I go about
doing this?
--
-----------
Thanks,
Steve
Oct 10 '06 #1
3 1610

Maybe you can get some ideas here
9/21/2005
XmlSerializatio n with IDictionary and CollectionBase Objects
http://sholliday.spaces.live.com/?_c...26ayear%3d2005
But for
#1
I'd write a "wrapper" object to handle this. Like, if you needed to
serialize a Plant object, Person object, Animal object......... you could
create a
ThingWrapper class, with 3 properties (1 for a Plant, 1 for a Person, 1 for
an Animal), and serialize the ThingWrapper.
OR
You can do each thing individually, and roll your own "xml merger", but
you'd have to do alot of work here. And when you needed to pull them out,
you'd have to use SelectNodes or SelectSingleNod e, and get the innerXml to
serialize each object. This is why I mention the ThingWrapper above.

#2 related to #1.

Check out my blog code...........

But the ThingWrapper is where I'd look to. That, or using the blog code to
figure out how to serialize collections of objects.


"SteveT" <St****@newsgro ups.nospamwrote in message
news:62******** *************** ***********@mic rosoft.com...
I want to be able to deserialize data contained within a XML file to a
data
structure. This I know how to do. However, what I want to be able to do
is
the following:
1. Serialize multiple "C# classes" into a single XML file. One at a time.
2. Deserialize each "C# class" from the XML file. One at a time.

Is this possible? I don't see a way to do this. If it isn't possible
does
anyone have a suggestion on how to get around a problem I have. I have
many
data structures that I need to save to disk and later retrieve when a
program
runs. The data structures are contained in nodes of a TreeView list. If
I
serialize each structure one-by-one I may have hundreds of XML files. I
want
to group certain TreeView node-paths all under a single XML file to have
fewer XML files to manage and thus make things easier. How could I go
about
doing this?
--
-----------
Thanks,
Steve

Oct 10 '06 #2
You can put them into a Generic Collection, and serialize the Collection.

--
HTH,

Kevin Spencer
Microsoft MVP
Chicken Salad Shooter
http://unclechutney.blogspot.com

A man, a plan, a canal, a palindrome that has.. oh, never mind.

"SteveT" <St****@newsgro ups.nospamwrote in message
news:62******** *************** ***********@mic rosoft.com...
>I want to be able to deserialize data contained within a XML file to a data
structure. This I know how to do. However, what I want to be able to do
is
the following:
1. Serialize multiple "C# classes" into a single XML file. One at a time.
2. Deserialize each "C# class" from the XML file. One at a time.

Is this possible? I don't see a way to do this. If it isn't possible
does
anyone have a suggestion on how to get around a problem I have. I have
many
data structures that I need to save to disk and later retrieve when a
program
runs. The data structures are contained in nodes of a TreeView list. If
I
serialize each structure one-by-one I may have hundreds of XML files. I
want
to group certain TreeView node-paths all under a single XML file to have
fewer XML files to manage and thus make things easier. How could I go
about
doing this?
--
-----------
Thanks,
Steve

Oct 10 '06 #3
Great minds must think alike! :) Sloan's first comment got me to thinking
that an array of these objects could be written to an XML file. I just
completed the test code and sure enough it works.

Thanks to you both.
--
-----------
Thanks,
Steve
"Kevin Spencer" wrote:
You can put them into a Generic Collection, and serialize the Collection.

--
HTH,

Kevin Spencer
Microsoft MVP
Chicken Salad Shooter
http://unclechutney.blogspot.com

A man, a plan, a canal, a palindrome that has.. oh, never mind.

"SteveT" <St****@newsgro ups.nospamwrote in message
news:62******** *************** ***********@mic rosoft.com...
I want to be able to deserialize data contained within a XML file to a data
structure. This I know how to do. However, what I want to be able to do
is
the following:
1. Serialize multiple "C# classes" into a single XML file. One at a time.
2. Deserialize each "C# class" from the XML file. One at a time.

Is this possible? I don't see a way to do this. If it isn't possible
does
anyone have a suggestion on how to get around a problem I have. I have
many
data structures that I need to save to disk and later retrieve when a
program
runs. The data structures are contained in nodes of a TreeView list. If
I
serialize each structure one-by-one I may have hundreds of XML files. I
want
to group certain TreeView node-paths all under a single XML file to have
fewer XML files to manage and thus make things easier. How could I go
about
doing this?
--
-----------
Thanks,
Steve


Oct 10 '06 #4

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

Similar topics

1
1856
by: Thomas | last post by:
Hi, I implemented a composite pattern which should be serializable to xml. After spending some time in the newsgroups, i finally managed serializing, even with utf-8 instead of utf-16, which causes ie problems. But when deserializing the xml into the object structure, the following exception is beeing thrown: There is an error in XML document (3, 701).
3
8087
by: Chrigel | last post by:
Hi all, We have problems deseralizing objects previously serialized as XML. This did work fine with .NET 1.1 but since we have installed SP1, deserializing fails (but serializing works). The error occurs within the following line "return formatter.Deserialize(xmlReader) as ParameterList;" and the "innerexception" sais "The root element is missing.". Thanks for any hints
4
7512
by: Wayne Wengert | last post by:
Using VB.NET I want to read in an XML file that has an array of objects and then step through the resulting array in code. I build a class to define the structure and I am running code to read in the data but I can't figure out where the data is in the resulting array. Most of the relevant code is below. When I run the code to desrialize I get no errors but if I try to look at some of the data via the command window I get errors such as...
2
3098
by: Earl Teigrob | last post by:
I am saving and restoring value types such as Int32, DateTime and Boolean in strings. I was wondering if there is a mechanism build into .NET for serializing and deserializing these to string format. I can, of course, serialize a class to a file, either binary or XML, but this is not what I am looking for. Currently I am using ToString() or Convert.xxx to do this, but thought that if there was a true serializer, deserializer, that would be...
1
1446
by: Bob Rock | last post by:
Hello, always having to validate an XML stream against a XSD may add up an important overhead. My XMLs are usually the result of serializing a class instance and often in my applications what I end up doing is just deserializing it back into a new instance of the same class. Considering what I just said what I often end up doing is not validating my XML to be deserialized and just try deserializing it into an instance of the class and...
5
3161
by: Daniel Gackle | last post by:
I'm getting a strange ArgumentNullException after deserializing a SortedList. Haven't seen this discussed in the newsgroups, but it looks like a bug - unless I missed something obvious? I've distilled the problem into the following code. Can anybody reproduce/explain the problem? Thanks, Daniel
6
1583
by: Steve Teeples | last post by:
I use serialization to write class data to a file. During my development of this class I need to add properties or fields on occation. After adding a property, when deserializing the data saved to disk I get an exception error indicating that the class data members no longer match. To avoid the exception errors, how can I retrieve data from the disk and populate the existing fields found within the file and set defaults for the new...
0
7815
by: Sivajee Akula | last post by:
Hello All, I am trying to consume a .NET Service from Adobe LiveCycle Workflow. The service deals with complex objects. I am getting the following exception at the time of invocation of the service, and due to which my workflow gets stalled. When I searched the net, I found many posts reporting this error, but none with a solution. There is no code involved in the invocation, everything is handled by Adobe tool itself. I just specify the...
1
11816
by: =?Utf-8?B?SmVyZW15X0I=?= | last post by:
I am working on an order entry program and have a question related to deserializing nodes with nested elements. The purchase order contains multiple line items which I select using an XmlNodeList. I am trying to deserialize the nodes using a foreach as follows: foreach(XmlNode lineItem in LineItemsNodeList) An abbreviated example of the nested lineItem node looks like this:
0
1806
by: William LaMartin | last post by:
I have created a web service that simply uses WebClient to retrieve the text of a web page. If I access the asmx page with my browser and put in a URL, it retrieves the text of that page with no problem--no matter how large the page length. When I try to consume this service in a VB.net desktop application, everything is fine for a page with a small amount of text. However, if the page has just a moderate amount of text, I receive the...
0
10046
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
9886
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
9857
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,...
1
7259
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
6542
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5155
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
5318
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3369
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2677
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.