I just started with xml for script this afternoon and ran into a "problem" in Firefox with the following sample code (at the end of the post).
The code works and does what it's supposed to do, but then the page "hangs"...which is to say that the mouse pointer has an hourglass that spins forever (as if the page were still loading) and other "tabs" (you know how Firefox can display multiple pages under separate tabs) run extremely slow and intermittently (e.g. there's an animated gif at the top of this page that runs normally for a few hundred milliseconds, then slows down/stops for half a second then speeds up again). I have Firefox version 2.0.0.4
This does not happen at all in IE 7.
Am I doing something wrong?
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>New Page 1</title>
<script src="/oig/xmlIO.js"></script>
<script src="/oig/xmlEscape.js"></script>
<script src="/oig/xmlsax.js"></script>
<script src="/oig/xmlw3cdom.js"></script>
<script language="javascript">
function loadLocalXML() {
/*
the XMLIO API handles all of the data retrieval.
all we need to do is tell it which file to load and what
function to call when it is finished
*/
xmlIOLoadLocalData("navtree.xml.html", "callbackFunction");
} //end function loadLocalXML
function callbackFunction(strXML) {
return true;
//display the returned XML data
alert(strXML);
//instantiate the W3C DOM Parser
var parser = new DOMImplementation();
//load the XML into the parser and get the DOMDocument
var domDoc = parser.loadXML(strXML);
//get the root node (in this case, it is ROOTNODE)
var docRoot = domDoc.getDocumentElement();
alert(docRoot.nodeName);
//get the first "TAG1" element
var firstTag1 = docRoot.getElementsByTagName("url").item(1);
//display the data
//it should be "Hello World"
alert(firstTag1.getFirstChild().getNodeValue());
parser = null;
} // end method callbackFunction
</script>
</head>
<body onload="loadLocalXML();">
</body>
</html>
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I just started with xml for script this afternoon and ran into a "problem" in Firefox with the following sample code (at the end of the post).
The code works and does what it's supposed to do, but then the page "hangs"...which is to say that the mouse pointer has an hourglass that spins forever (as if the page were still loading) and other "tabs" (you know how Firefox can display multiple pages under separate tabs) run extremely slow and intermittently (e.g. there's an animated gif at the top of this page that runs normally for a few hundred milliseconds, then slows down/stops for half a second then speeds up again). I have Firefox version 2.0.0.4
This does not happen at all in IE 7.
Am I doing something wrong?
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>New Page 1</title>
<script src="/oig/xmlIO.js"></script>
<script src="/oig/xmlEscape.js"></script>
<script src="/oig/xmlsax.js"></script>
<script src="/oig/xmlw3cdom.js"></script>
<script language="javascript">
function loadLocalXML() {
/*
the XMLIO API handles all of the data retrieval.
all we need to do is tell it which file to load and what
function to call when it is finished
*/
xmlIOLoadLocalData("navtree.xml.html", "callbackFunction");
} //end function loadLocalXML
function callbackFunction(strXML) {
return true;
//display the returned XML data
alert(strXML);
//instantiate the W3C DOM Parser
var parser = new DOMImplementation();
//load the XML into the parser and get the DOMDocument
var domDoc = parser.loadXML(strXML);
//get the root node (in this case, it is ROOTNODE)
var docRoot = domDoc.getDocumentElement();
alert(docRoot.nodeName);
//get the first "TAG1" element
var firstTag1 = docRoot.getElementsByTagName("url").item(1);
//display the data
//it should be "Hello World"
alert(firstTag1.getFirstChild().getNodeValue());
parser = null;
} // end method callbackFunction
</script>
</head>
<body onload="loadLocalXML();">
</body>
</html>