loadXML from file and String problem on Firefox
I am new to JavaScript/XML, I am trying to load xml file as well as xml as string input, and have written following code. This is working in IE but not in FireFox, can anyone help?
-------------------------------------------------------------------------------------------------------
function MyXML() {
try{
this._xmlDoc=new ActiveXObject("Microsoft.XMLDOM");
this._flag = 1;
}
catch(e)
{
try{
this._xmlDoc=document.implementation.createDocumen t("","",null);
this._flag = 2;
}catch(e) {alert(e.message);}
}
}
MyXML.prototype._xmlDoc;
MyXML.prototype._xmlObj;
MyXML.prototype._firstElementText;
MyXML.prototype._flag;
MyXML.prototype.loadXMLFile = function(xmlFile)
{
try{
this._xmlDoc.async="false";
//this._xmlDoc.onreadystatechange=verify;
this._xmlDoc.load(xmlFile);
this._xmlObj=this._xmlDoc.documentElement;
}catch(e) {alert(e.message)}
return this._xmlDoc;
}
MyXML.prototype.loadXMLString = function(xmlString, document)
{
if(this._flag == 1)
{
try{
this._xmlDoc=new ActiveXObject("Microsoft.XMLDOM");
this._xmlDoc.async="false";
this._xmlDoc.loadXML(xmlString);
this._xmlObj=this._xmlDoc.documentElement;
}catch(e) {alert(e.message)}
}
else if(this._flag == 2)
{
try{
this._xmlDoc=document.implementation.createDocumen t("","",null);
this._xmlDoc.async="false";
var parser=new DOMParser();
this._xmlDoc=parser.parseFromString(xmlString,"tex t/xml");
//this._xmlObj=this._xmlDoc.documentElement;
}catch(e) {alert(e.message)}
}
return this._xmlDoc;
}
---------------------------------------------------------------------------------------------------------------
|