Also ... an XSLT stylesheet (having nothing to do with CSS, etc ...) can dig through an XML structure and handle tasks like this without programming. If you find that you are going to be "writing a lot of little programs" to do this task, they might be a more comprehensive solution.