XML pretty printing and color highlighting .

We used to build many Flash Applications which exports data as XML. How about pretty printing it with colors?

Before writing my own code I searched to find any existing code and found this code written by Evgeniy Potapenko in prototype. It does the basic pretty printing part, but it had few problems in handling the text nodes. It adds tabs before text nodes and unlike the native .toString() function it does not html encode the special characters.
I’ve fixed those issues and added color highlighting feature. Here you can see the demo of the outcome. Just copy paste an XML string in to the text area.

Once I’ve optimized the code I will post it here.

Leave a Reply