CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Oct 2003
    Posts
    72

    Load xml from Javascript

    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)
    }

  2. #2
    Join Date
    May 2002
    Posts
    10,943

    Re: Load xml from Javascript

    ActiveX only works in IE. However, Mozilla also does support XML. Read/Learn about it here.

    EDIT: Here is a great example of XML implementation in Firefox (Mozilla based browser).
    If the post was helpful...Rate it! Remember to use [code] or [php] tags.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured