tags:

views:

55

answers:

2

I'd like to display XML pulled from a database on a website. I'd like to be able to style how it is displayed (such as different colors for string value, attributes, elements,..).

How would you do this? Can you use CSS? Thanks!

EDIT: I mean display the XML as XML editor would, sorry for the confusion!

+3  A: 

Have a look at XSL/XSLT.

jtbandes
A: 

(I'm interpreting your question to be about displaying the XML content as XML, but with pretty syntax highlighting, as you would get with an XML editor for example.)

I'd recommend xmlverbatim via an XSLT transform (either server-side or via JavaScript). You can change its indent-elements parameter to control whether you want it to indent the XML.

For the XSLT transform on the client side, xslt.js (possibly in conjunction with jQuery) should help.

Bruno
Yeah, that's what I mean. I edited the question :). I'll take a look at xmlverbatim!
evan
Don't forget to include the CSS file provided if you want the pretty colours.
Bruno
Thanks that helped!
evan