loading xml file as string on firefox

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • rahat09
    New Member
    • Sep 2008
    • 2

    loading xml file as string on firefox

    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?


    -------------------------------------------------------------------------------------------------------
    [CODE=javascript]function MyXML() {

    try{
    this._xmlDoc=ne w ActiveXObject(" Microsoft.XMLDO M");
    this._flag = 1;
    }
    catch(e)
    {
    try{

    this._xmlDoc=do cument.implemen tation.createDo cumen t("","",null) ;
    this._flag = 2;

    }catch(e) {alert(e.messag e);}
    }

    }

    MyXML.prototype ._xmlDoc;
    MyXML.prototype ._xmlObj;
    MyXML.prototype ._firstElementT ext;
    MyXML.prototype ._flag;


    MyXML.prototype .loadXMLFile = function(xmlFil e)
    {
    try{
    this._xmlDoc.as ync="false";
    //this._xmlDoc.on readystatechang e=verify;
    this._xmlDoc.lo ad(xmlFile);
    this._xmlObj=th is._xmlDoc.docu mentElement;
    }catch(e) {alert(e.messag e)}

    return this._xmlDoc;
    }

    MyXML.prototype .loadXMLString = function(xmlStr ing, document)
    {
    if(this._flag == 1)
    {
    try{
    this._xmlDoc=ne w ActiveXObject(" Microsoft.XMLDO M");
    this._xmlDoc.as ync="false";
    this._xmlDoc.lo adXML(xmlString );
    this._xmlObj=th is._xmlDoc.docu mentElement;
    }catch(e) {alert(e.messag e)}
    }
    else if(this._flag == 2)
    {
    try{
    this._xmlDoc=do cument.implemen tation.createDo cumen t("","",null) ;
    this._xmlDoc.as ync="false";
    var parser=new DOMParser();
    this._xmlDoc=pa rser.parseFromS tring(xmlString ,"text/xml");
    //this._xmlObj=th is._xmlDoc.docu mentElement;
    }catch(e) {alert(e.messag e)}

    }

    return this._xmlDoc;
    }
    [/CODE]
    ---------------------------------------------------------------------------------------------------------------
    Last edited by acoder; Sep 17 '08, 10:47 PM. Reason: Added [code] tags
  • acoder
    Recognized Expert MVP
    • Nov 2006
    • 16032

    #2
    This link may help. If not, do you get an error message in your code?

    Comment

    Working...