Click to See Complete Forum and Search --> : Load xml from Javascript


elektroman
August 3rd, 2007, 10:26 AM
Hi guys

I have to load a file xml from javascript and to put all the content of it into a string to display

I have this code that in IE works but not in mozilla can you help me

if (window.ActiveXObject)
{
//Checking if the browser is IEvar
xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
xmlDoc.async="false";
xmlDoc.load("note.xml");
if (xmlDoc.parseError.errorCode != 0)
{
var myError = xmlDoc.parseError;
alert("You have error " + myError.reason);
}
else
{
alert(xmlDoc.xml)
}
}
else if (document.implementation && document.implementation.createDocument)
{
xmlDoc = document.implementation.createDocument("","", null);
xmlDoc.async = false;
xmlDoc.load("note.xml");


result = processor.transformToDocument(xmlDoc);


xmls = new XMLSerializer();
output = xmls.serializeToString(result);
alert(output)
}

PeejAvery
August 4th, 2007, 09:57 AM
ActiveX only works in IE. However, Mozilla also does support XML. Read/Learn about it here (http://developer.mozilla.org/en/docs/XML_in_Mozilla).

EDIT: Here (http://www.ibm.com/developerworks/library/x-ffox3/) is a great example of XML implementation in Firefox (Mozilla based browser).