Display indented XML code within a HTML page

Posted by Efrain on Stack Overflow See other posts from Stack Overflow or by Efrain
Published on 2012-04-12T09:37:59Z Indexed on 2012/04/12 11:29 UTC
Read the original article Hit count: 172

Filed under:
|
|
|

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

© Stack Overflow or respective owner

Related posts about .NET

Related posts about html