Hi I\'m looking for a way to render an XML document, that I retrieve using ajax, to a new browser window.
I am using JQuery\'s ajax() function to post JSON data to
The following will work only in FireFox and Opera, but i think is worth mentioning ..
window.open('data:text/xml,' + encodeURIComponent( jqXHR.responseText ) );
should work with chrome as well but it seems to treat window.open
differently than a usual URL.. if you just type the resulting url in chrome it works there as well..
Update This works with all browsers !
The thing is that javascript has the ability to tranform xml using xslt.
But not automatically, so we need to find the XML file for the reference to the XSLT file and load that as well. Then we can do the transformation in javascript and pass the resulting html to the new window.
Naturally IE handles thing differently than the rest.
$.get('xml-file-here.xml',
function(xmlData){
var xml = xmlData;
//extract the stylesheet so we can load it manually
var stylesheet;
for (var i=0;i