views:

109

answers:

2

Hi, I have a problem in reading and loading items of a collection which belongs to another collection in vb 2005.Those are all nodes of xml file. For exemple:

Toto is a node in xml file, an item of collection Tocollect and also a child-node of Tocollect, Tocollect is an item of Collect and a child-node of it.

When write the code, are there any differences between this situation and that a single object belongs to a collection or a collection belongs to an object?

A: 

In .NET there are referenced-types and value-types. Overwhelming majority of classes are referenced-types, it means that an variable as some class instance is an analogue of C++ pointer.

So two items of two different collections are the same thing/variable/instance/pointer.

abatishchev
A: 

In general if your object are connected in a hierarchy then your xml should reflect that hierarchy for example.

Your Node has a bunch of Nodes which has a bunch of nodes.

This is opposed to the scheme where you have a list of all then another list of all then yet another separate list of . Now you could maintain three separate lists (treating like tables in a database) if you use unique ids to tie the nodes to together. However you will have an extra step when you read in the XML to convert it into your object hierarchy.

As for storing a hierachy. Basically you have each object implement a Read and a Store method. If a parent contains childs then it should loop through each child calling it's store method passing it the stream or parameters needed to store it in the correct place.

RS Conley