Why reinvent the wheel when it comes to syntax coloring? Many have written XSLT stylesheets that output a colored version in HTML of the input XML document. Colorer provides a nice alternative. It can color source written in a fair amount of programming languages in addition to XML, and you can even try it online.