is there a generic way of outputing to the screen (or maybe file) a tree?

i have a programmng assignment of which i have to choose 1 out of 4 possibilites for my HTML Web Design class ....

1 of them that im thinking is taking a html file (that is valid xhtml 1.0 strict) and outputting the html stree structure ....

i can already take the file, and split it up into its elements (tree branches) ... just, outputting it to display like a tree, im not sure how to take on that task ....

any basic example will help ....

>any basic example will help ....
Preorder traversal. Search the web.