Prima di tutto dovrebbe essere un pò modificata la funzione ajaxLoader:
codice:
function ajaxLoader(url,id,fn)
{
if (document.getElementById) {
var x = (window.ActiveXObject) ? new ActiveXObject("Microsoft.XMLHTTP") : new XMLHttpRequest();
}
if (x)
{
x.onreadystatechange = function()
{
if (x.readyState == 4 && x.status == 200)
{
if(id) {
var el = document.getElementById(id);
else el.innerHTML = x.responseText;
}
if(fn) fn(x);
}
}
x.open("GET", url, true);
x.send(null);
}
}
Ora dovresti essere in grado di fare una cosa del genere:
Codice PHP:
function appendXML(id,xml,xsl) {
ajaxLoader(xml, null, function(xml) {
ajaxLoader(xsl, null, function(xsl) {
if(xml.tranformNode)
xml = xml.tranformNode(xsl);
else {
xml = (new XSLTProcessor());
xml.importStylesheet(xsl);
xml = xml.transformToFragment(xml, document);
}
document.getElementById(id).appendChild(xml);
})
})
}
<body onload="appendXML('contenuto', 'file.xml', 'file.xsl')">
Spero funzioni