Visual Studio displays XML on a special text box which
- Properly indents the XML hierarchy;
- Angle brackets are blue;
- Elements are brown;
- Attributes are red;
- Strings are blue
- Comments are green.
Where can I get a special “TextBox” like this, in C#, which is specialized to display XML to use in my code?
Note I don’t need a whole library with a lot of functionalities – all I need is a TextBox that display XML in different colors and indents.
Many thanks!
I don’t think you’ll find a simple textbox as it is rather complex to handle syntax highlighting. A good open-source solution for this that I have used in past is SharpDevelop from ICSharpCode. Part of the full IDE is a textbox-like control that you can use in your own application without the full-blown IDE.
Another option if you just want to display the XML, without editing, is to display the XML using the web browser, embedded as a user control. Not very light-weight, but definitely possible.