Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

Hi guys,

 

I am having REAL difficulty getting something to work. I have a simple class and associated collection class. The class has a few properties, and the collection class houses instances of the classes.

 

The class looks basically like this i pseudo code

 

Class Student()

Name as String

Age as Integer

Address as String

End Class

 

The collection class is just a list of the students.

 

I can easily serialize the collection class s_c, which we can assume I've already filled with students:

 

imports system.io

imports system.xml.serialization

 

dim serializer as new xmlserializer(gettype(student))

dim sw as new streamwriter("data.xml")

dim s as new student

 

for each s in s_c

serializer.serialize(sw,s)

next s

 

This creates an xml document, as I require. But how do I get that xml data back from the xml file into my student collection via the student class? What I mean is, I want to read each students data back into an instance of the student class, and add it to the student collection. The reverse of the above process.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...