Solved

reading and parsing remote xml-file in Mozilla

Posted on 2004-04-09
3
1,022 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

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

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…
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
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…
Suggested Courses

732 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