I am trying to save and read back a tree like this:
a - b - c - d - e - f - g - h // main branch
d2 - e2 - f2 - g2 // branch 2
f3 - g3 - h3 - i3 - l3 - m3 //branch 3
I was thinking of using xml for this but I am not sure it’s the best tool for the job. I could make b child of a, c child of b, d and d2 child of c, etc… but how to navigate the tree efficiently? I try to explain.
The tree will be associated to a Canvas which will show its content just like in code block above. If the user clicks on e2, for example, he could add data to that branch, that is f2, or create a new branch, that is f3. It means that when the user clicks on e2 I have to move to that particular node of the xml. How to do it efficiently?
XML is a tree structure by nature, so it should work for what you want. You would have to associate an XMLNode with each “object” on the canvas, but that shouldn’t be too difficult. When you click on an object in the canvas, you get an XMLNode. At that point, you can operate on its child nodes without concern for where it is in the hierarchy.
Interesting. So I could create an array of XmlNode to be associated to the Canvas so that when I click on a specific position of the Canvas I get the corresponding XmlNode. Does it make sense to you? Or there’s something better?