Use a stack? Whenever you start a new list, push the corresponding closing tag onto a stack. Whenever your "indent level" decreases, pop the stack and write out the closing tag you get.It's straightforward to use a python list as a stack.
Thanks for the tip, Kushal. Do you have a short code example for me? Regards Nico -- http://mail.python.org/mailman/listinfo/python-list