Solved

reading and parsing remote xml-file in Mozilla

Posted on 2004-04-09
3
1,021 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

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

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…
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
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…

749 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