XML and JTree - Exact structure possible?

I've been trying to convert my JTree (which is completely editable by the user) into XML format, but currently not having much luck.

So far I have a Vector for holding the information on each node created (whether it is a leaf or not basically, the class also holds the TreePath of the node). And I was going to use the data from the Vector to try and develop my XML file.

I've been attempting to loop through every value of the Vector and add it to my XML document, but the problem arises when trying to add the nodes to their parents. With the availability of the TreePath of the node I was hoping that maybe someone could point me in the direction of using each value of the TreePath to get to the correct element.

I hope I've explained my situation well enough, I'll be watching this thread so ask any questions.

Thanks in advance!

[870 byte] By [Dannetha] at [2007-10-3 4:32:47]
# 1
http://www.stylusstudio.com/xmldev/200207/post80020.html
dvohra09a at 2007-7-14 22:36:20 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...
# 2

I've thought of doing that, but the problem being is it can be nested many times.

So the structure of the JTree may look like this:

[rootNode]

[leafNode]

[anotherLeafNode]

[aNode]

[anotherNode]

So if it's like that, then just looping through the roots children wouldn't retrieve [aNode], as you wouldn't be looping through [anotherLeafNode]'s children.

Message was edited by:

Danneth

Dannetha at 2007-7-14 22:36:20 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...
# 3
So why not just start at the root and go through the nodes recursively and build your XML as you do that? This Vector idea just seems to be more trouble than it's worth as a Vector is a linear sequence of things and a tree, well, isn't a linear sequence of things.
DrClapa at 2007-7-14 22:36:20 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...