<br><font size=2 face="Arial">&gt;&gt;This works great. Though i tried to figure out what is happening but can't quite get it. Could u maybe explain what happens here(or point me to a site which &gt;&gt;explains it), how is the tree like structure made? And why doesn't it work in my piece of code? Als i wonder if it would be easy to also list the attributes and &gt;&gt;labels?</font>
<br>
<br><font size=2 face="sans-serif">I don't know of any site which explains it. The underlying principle is &quot;Recursion&quot;.</font>
<br>
<br><font size=2 face="sans-serif">You start with the root node and then call a method to add the children, the method that adds a child calls a method (actually itself) to add its own children (which calls itself again to add its children, recursively) before moving onto the next element. Trying to work out what level you are on and remember where you are in the tree hierarchy is a nightmare to do when trying to represent it at a flat level. Because the variables in the method call are local to it you can nest the calls without having to keep track of where you are as you get one add children method call per nested element.</font>
<br>
<br><font size=2 face="sans-serif">Don't know if I can explain it much better.</font>
<br>
<br><font size=2 face="sans-serif">for a document like</font>
<br><font size=2 face="sans-serif">&lt;root&gt;</font>
<br><font size=2 face="sans-serif">&nbsp; &lt;a&gt;</font>
<br><font size=2 face="sans-serif">&nbsp; &nbsp; &lt;x&gt;</font>
<br><font size=2 face="sans-serif">&nbsp; &nbsp; &nbsp; &nbsp;&lt;z/&gt;</font>
<br><font size=2 face="sans-serif">&nbsp; &nbsp; &nbsp;&lt;/x&gt;</font>
<br><font size=2 face="sans-serif">&nbsp; &nbsp; &lt;y/&gt;</font>
<br><font size=2 face="sans-serif">&nbsp; &lt;/a&gt;</font>
<br><font size=2 face="sans-serif">&nbsp; &lt;b/&gt;</font>
<br><font size=2 face="sans-serif">&lt;/root&gt;</font>
<br>
<br><font size=2 face="sans-serif">root calls addChildren</font>
<br><font size=2 face="sans-serif">&nbsp; &nbsp;add Children adds a to root and then calls add children (to a)</font>
<br><font size=2 face="sans-serif">&nbsp; &nbsp; &nbsp; &nbsp; add children adds x to a then calls add children (to x)</font>
<br><font size=2 face="sans-serif">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; add children adds z to x</font>
<br><font size=2 face="sans-serif">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; exit method</font>
<br><font size=2 face="sans-serif">&nbsp; &nbsp; &nbsp; &nbsp; add children adds y to a</font>
<br><font size=2 face="sans-serif">&nbsp; &nbsp; &nbsp; &nbsp; exit method</font>
<br><font size=2 face="sans-serif">&nbsp; add children adds b to root</font>
<br><font size=2 face="sans-serif">&nbsp; exit method</font>
<br><font size=2 face="sans-serif">end calling sequence</font>
<br>
<br><font size=2 face="sans-serif">The Java I base my development on is attached if it is any use.</font>
<br><font size=2 face="sans-serif">The tree note uses the user objects toString method to display the tree node. That is why I use an extended Element (Elementx) class so that I can override the toString method in Element to provide the representation in the tree that I want. There is a simple document viewer that shows the JTree formatting</font>
<br>
<br>
<br>