Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

(De)Serializing multiple objects from single file. 1

Status
Not open for further replies.

JBlair

Programmer
May 30, 2003
76
0
0
US
Is it possible to do as the subject suggests?

Here's what I'm trying to do:

I'm using an XML file to keep track of connection info for a client program. As the user saves connection data, I want to be able to save each connection to the same file, and later reload each connection from that file.

My Connection class is very simple, a connection object only has 3 properties, no methods except the get/set blocks.

Name
Description
IPEndPoint (using the ToString() Method)

If its possible I expect the XML file to look similar to this:

[tt]
<Connection>
<Name>
LocalHost
</Name>
<Description>
The localhost server.
</Description>
<IPEndPoint>
127.0.0.1:13000
</IPEndPoint>
</Connection>
<Connection>
<Name>
OtherHost
</Name>
<Description>
The other local server.
</Description>
<IPEndPoint>
127.0.0.1:11000
</IPEndPoint>
</Connection>
[/tt]
 
you'll need to create an object which accepts a filename into the constructor. then load the file into an xmlreader. parse through the file and load the attributes into new instances of your connection objects.

Jason Meckley
Programmer
Specialty Bakers, Inc.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top