Displaying XML with JavaScript

Discussion in 'XML' started by clocke, Feb 16, 2010.

  1. clocke


    Mar 25, 2009
    Likes Received:
    On the following HTML page, the JavaScript writes the XML perfectly using the document.write method so that it appears as if the XML page had been opened in the browser.

    <script language="javascript" type="text/javascript">
    function displayResult() {
    xmldoc = new ActiveXObject("Microsoft.XMLDOM");
    xmldoc.async = false;

    xsldoc = new ActiveXObject("Microsoft.XMLDOM");
    xsldoc.async = false;
    //document.getElementById("example").innerHTML = xmldoc.transformNode(xsldoc);
    <body onload="displayResult()">
    <div id="example"></div>

    However, if I uncomment the line prior to the document.write line, and comment that line, so that the XML appears within the div, none of the styles from the defaultss.xslt page are applied. Can somebody please tell me how to make the XML appear with all of the styles applied within the div?

    Message length restriction prevents me from posting the defaultss.xslt code, but, as I said, it works perfectly with document.write, so I assume that I am missing something amazingly simple that is beyond my negligible knowledge of XML.
    clocke, Feb 16, 2010
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.