This example shows how to use cross-browser DOM without the use of a javascript library like Sarissa. The code works on Opera 9, IE6/7/8, Firefox 1/2/3, Safari 1.2, Chrome 1.0.
This page will remain online for future reference. The original question can be viewed at Experts-Exchange, but requires (free) membership. More information about me, about how this site is maintained and about how to use these pages for yourself, check out the opening page.
If all goes well, the three paragraphs below should change after clicking the button:
para item_0
para item_1
para item_2
function loadXML(file){
try //Firefox, Mozilla, Opera, IE7/8 etc.
{
var req = new XMLHttpRequest();
req.open("GET", file, false);
req.send(null);
return req.responseXML;
}
catch (e) {
try //Internet Explorer IE4/5/6
{
var xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
xmlDoc.async = false;
xmlDoc.load(file);
return xmlDoc;
}
catch (e) {
alert(e.message);
return null;
}
}
}