javascript - Using window.open, document.open, and document.write to display XML (XML rendering gone) -


this related question, not duplicate. deals proposed solution have reached impasse.

i have following code reads xml, makes changes, opens window, , writes xml document. problem content not rendered xml. way set content type, etc, have browser handle content xml?

<script> var wxml; var xdoc; var xdevices, xinputs; var xdevice, xinput;      function fsetxmlainput(idevice, inode, nodenewval) {       xinput = xinputs[inode];       xvalue = xinput.getelementsbytagname("value")[0];        // change node value:       // console.log("nodeval: " + xvalue.firstchild.nodevalue);       xvalue.firstchild.nodevalue = nodenewval;       // console.log("newval: " + xvalue.firstchild.nodevalue);     }      function fsetxmldevice(idevice) {       xdevice = xdevices[idevice];       xinputs = xdevice.getelementsbytagname("input");         fsetxmlainput(idevice, 0, "22");         fsetxmlainput(idevice, 1, "33");     }      function alternativeloadxml3() {         // load xml file         if (window.xmlhttprequest) {             xhttp = new xmlhttprequest();         } else { // ie 5/6             xhttp = new activexobject("microsoft.xmlhttp");         }          xhttp.open("get", "my_template.xml", false);         xhttp.send();          xdoc = xhttp.responsexml;         xdevices = xdoc.getelementsbytagname("device");         fsetxmldevice(1);          var xmltext = serializexmlnode(xdoc);          var newwindow = window.open("my_template.xml", "test", "width=300,height=300,scrollbars=1,resizable=1");         newwindow.document.open();         newwindow.document.write(xmltext);         newwindow.document.close()     };  </script> 

below xml well:

<?xml version="1.0" encoding="utf-8"?> <myxmlroot> <device>   <input><name>"name 1"</name><value>{replaceme!}</value></input>   <input><name>"name 2"</name><value>{replaceme!}</value></input>   </device> <device>   <input><name>"name 1"</name><value>{replaceme!}</value></input>   <input><name>"name 2"</name><value>{replaceme!}</value></input>   </device> <device>   <input><name>"name 1"</name><value>{replaceme!}</value></input>   <input><name>"name 2"</name><value>{replaceme!}</value></input>   </device> </myxmlroot> 

any way force browser render content in new window xml...or using document.open , document.write mean code rendered html?

related: change xml content using javascript, missing refresh

both document.open , document.write used write html or javascript document. goes dom level 2 specification of document.open, assumes document opened in order write unparsed html.

instead of using document.open , document.write, instead suggest dymanically adding elements using xml dom in sampleelement.appendchild(xmlnode)

a similar question can found here: how display xml in javascript?


Comments

Popular posts from this blog

linux - xterm copying to CLIPBOARD using copy-selection causes automatic updating of CLIPBOARD upon mouse selection -

qt - Errors in generated MOC files for QT5 from cmake -