Help | Site Map
Connecting Tech Pros Worldwide
Reply
 
LinkBack Thread Tools
  #1  
Old September 16th, 2008, 01:38 PM
Newbie
 
Join Date: Sep 2008
Location: Sydney
Age: 29
Posts: 2
Default 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;
}

---------------------------------------------------------------------------------------------------------------
Reply
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over network members.
Post your question now . . .
It's fast and it's free

Popular Articles