| || |
I've parsed an XML document and created a root node that contains all of its descendants. Here is the definition of the node:
[-] type rNODE is record
[ ] string tagName
[ ] string tagValue
[ ] list of string tagAttributes
[ ] list of rNODE children
[ ] rNODE parentNode
[ ] list of rNODE siblings
Everything looks fine and I can recursively go through the list of children and display all nodes in the document. However, I have not yet populated the parentNode or siblings list.
The first thing I want to do is assign the parentNode. This seems easy enough. I should be able to loop through a node's list of children as such:
for i=1 to ListCount(node.children)
node.children[i].parentNode = node
However, doing this creates a really heavy object since a parentNode contains all its descendant nodes. I would like to create some type of pointer to the parentNode so that I can extract information from it when needed. For instance, I may be working with a node and need information from its parent or grandparent and need a way to get to that data. Is there a way to do this? Is there a way to insert a reference to the parentNode? Any suggestions?
Rather than storing the whole node in the record, could you just store the name of the parent node? Or maybe I'm just not understanding your problem.
A concerned Borland customer, a fly in the ointment, a wrench in the works.