Solved

reading and parsing remote xml-file in Mozilla

Posted on 2004-04-09
3
1,018 Views
Last Modified: 2007-12-19
I have these functions:

===================================
function LoadXMLFile(sURL) {
    var oXML;
    try {
        oXML = new ActiveXObject('Msxml2.DOMDocument');
    } catch(e) {oXML = false;}
    if(oXML) {
        //IE load XML document
        oXML.async = false;
        oXML.load(sURL);
        if(oXML.parseError.errorCode) {
            alert('error: ' + oXML.parseError.description);
            return false;
        }
    }
    if(!oXML) {
        //Mozilla load XML document
        try {
            oXML = document.implementation.createDocument("", "", null);
        } catch(e) {oXML = false;}
        if(oXML) {
            try {
                oXML.load(sURL);
            } catch(e) {oXML = false;}
        }
    }
    return oXML;
}



function ConfirmTask(iTaskId, iPersonId, oCheckbox) {
    var bChecked = oCheckbox.checked;
    var sURL = '../rooster/ConfirmPersonPlanning.asp?task_id='+iTaskId+'&person_id='+iPersonId+'&confirm='+bChecked;

    var oXML = LoadXMLFile(sURL);
    if(oXML) {
        var sResult = parseInt(oXML.firstChild.text);  // <<====== here is the line with the error
        alert(sResult);
        if(!sResult) {
            oCheckbox.checked = !oCheckbox.checked;
            alert('it did not work');
        } else {
            alert('ok');
        }
    } else {
        oCheckbox.checked = !oCheckbox.checked;
        alert('no support for this');
    }
    return false;
}
=======================

It works fine in IE, but Firebird (0.8)  returns an error

oXML.firstChild.text has no properties. Apparently something goes wrong the loading the XML. I looked at a lot of documentation, but i could not find a solution.

How can i make the thing work in Mozilla ??
0
Comment
Question by:sybe
3 Comments
 
LVL 12

Accepted Solution

by:
ahosang earned 250 total points
ID: 10793343
text is not a valid w3c DOM property of a node. Try:
parseInt(oXML.firstChild.firstChild.nodeValue)
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
html input 8 42
VBScript on Html 15 47
Responsive Font Size 6 26
Using toggleClass to resize Bootstrap columns 7 18
Avoid defining the variables in the global scope; trying to define them in a local function scope. Because:   • Look-up is performed every time a variable is accessed.   • Variables are resolved backwards from most specific to least specific scope…
In my daily work (mainly using ASP.net), I need to write a lot of JavaScript code. One of the most repetitive tasks I do are the jQuery Ajax calls. You know: (CODE) I don't know if for you it's the same, but for me is soooo tedious to write the …
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

856 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question