views:

662

answers:

2

I have a page that users are able to add xml markup into a text area input. I'd like after they enter it that it be color-coded and formatted as xml would look in an IDE such as Visual Studio. Anybody know of a script or tool that would allow for this within a client-side browser?

+2  A: 

Short answer: you can't.

Not in an TEXTAREA, as the one here in SO.

The example in SO is very good, as it has a TEXTAREA where we type the text, and a DIV box below where you can see what you type formatted.

You could also go through the contentEditable = "true", but it's a real pain to do it properly...

Paulo Santos
+4  A: 

Take a look at CodeMirror, a syntax-highlighting editor in Javascript for browsers. This is an example for XML editing.

Brian Agnew