I want to display XML indentation on an html page inside <code></code>
I get XML as from a javascript function
new XMLSerializer()).serializeToString(newXMLDoc)
which gives me an unintended XML string.
One way that I can think of is to use <ul>
and <li>
But is there a better way to do this?
Can XSLT help me in this case (sorry, I don't know much about XSLT
). If so, where do I need to attach the XSLT stylesheet, in the html document or in the xmlString
, which I am adding to the <code></code>
.
The only client application that I can not do on the server side.
UPDATE: I also replace <and> in xmlString with <
and >
can i use XSLT?
Even after applying XSLT provided by Dimitre Novatchev, I donβt get indented text, although I see that XML is indented when I use XSLT using the SAXON parser core, but when I do this in my javascript code, I get the same Inappropriate code.
//var xslt contains the XSLT provided by Dimitre Novatchev as string //var XMLDoc is the XMLDocument object to be transformed xsltProcessor=new XSLTProcessor(); xsltProcessor.importStylesheet(xsl); newXMLDoc = xsltProcessor.transformToDocument(xml,document); //This is how I am converting the transformed XML to string return (new XMLSerializer()).serializeToString(newXMLDoc)
source share