in reply to Beautifying some SGML?

If your data is a tag soup, you won't be able to use XML or SGML tools. Actually, SGML tools are pretty dangerous in that case, because they might try harder to cope with your data and infer missing tags for example, which might not be what you want at all. Plus you would need a DTD, which you don't mention to have.

In you case your best bet is a simplistic regexp base tool. I'd try something like this one-liner:

perl -p -e's{<(.)}{ $ln= $level ? "\n" : ""; if( $1 eq "/") { $level--; } ; $indent= "  " x $level; if( $1 ne "/") { $level ++ }; $ln . $indent . $&; }eg' <filename>

It will work only if you don't have "compact" tags (<foo/>. And no CDATA section or any oddity of that sort. But it should be OK otherwise. As I said, you don't have XML data, so you don't get to play with all the cool XML toys ;--(