HTML Tree View with <ol> and <a href>

Gregor Horvath g.horvath at
Thu Jan 27 13:14:48 EST 2005


Before I reinvent the wheel I`d like to ask if someone has done this 
before since I did not find an advice at Google.

The goal is to create a dynamic Tree View in HTML.

Say I have a data strucure like this:

structList = 

I want to transform this into HTML:

<li><a href="?a=Sun">Sun</a></li>
   <li><a href="?a=Sun.1">Sun.1</a></li>
     <li><a href="?a=Sun1.1">Sun1.1</a></li>
     <li><a href="?a=Sun1.2">Sun1.2</a></li>
   <li><a href="?Sun.2">Sun.2</a></li>
     <li><a href="?a=Sun2.1">Sun2.1</a></li>
     <li><a href="?a=Sun2.2">Sun2.2</a></li>
<li><a href="?a=Kupa">Kupa</a></li>
   <li><a href="?a=Kupa1">Kupa1</a></li>

If the user clicks on a branch-link say 'Sun.1' then the branch below 
opens/closes (not printed by the servlet). Like a tree view control in 
an native GUI app.

Has this, or a similar approach, been done before in python ( I am using 


More information about the Python-list mailing list