I'm writing a small browser-side Javascript that parses XML from a file and modifies it. The output ideally would be a .xml file, but of course making a JS client write files is nearly impossible so I gave up on that.
I want Firefox to open a new window of contentType text/xml, with my serialized xml in it:
var xmlDoc = new XML(SourceXMLString); //SourceXMLString is read from an xml text file
output = window.open("");
output.document.open("text/plain");
output.document.write(xmlDoc.toXMLString());
output.document.close();
However any document.write instance seems to set the contentType to text/html and so all the tags are rendered wrong, naturally. From this fixed bug it seems that document.open creates the right contentType but document.write messes it up.
- This only needs to work in Firefox 2+.
- Server-side is not an option.
- I went with Javascript & Mozilla because of ECMAScript for XML support.