I have a programmatically created HTML document on which I would like to show some XML-code, fully formatted with line breaks and tabulators. That is, it should look like if you drag an xml file without a xml-stylesheet directly onto your browser (most browsers do some kind of xml-rendering with some default style sheet).
Now, I can of course escape all the characters (like <>, tab and newline) and do the indenting myself (using css styles, for example), but I was wondering whether I couldn’t re-use some ‘default’ xml-stylesheet from somewhere. Preferrably also one that has some javascript node-folding, too.
Do you know such a stylesheet/xslt? Or would you suggest another way to achieve this?
I’m using C#.
PS: I tried to use the XmlNotepad.DefaultSS.xslt from Microsoft’s XmlNotepad, but I couldn’t really get that working. :T
Why not use a SyntaxHighlighter .. like this one – it has an XML brush – example of XML here
All you need to do is wrap your XML in
<pre>tags and the rest is done for you – indentation, line numbers etc…