K
Kevin
Hi,
Meet importXML (see below). It merely imports an XML file to the
object, "xmlDoc."
When I call this function in-line, i.e. when I include the whole
importXML.js in the <HEAD>, I can access the XML elements sucessfully.
However, when I call this function externally, i.e. I include it in
the <HEAD> as a <javascript src = ".../importXML.js>, it fails to
work. It fails because alerts tell me that a sample XML file has a
length of 19, when in fact it has a length of 9. I confidently say
that it's 9 because the function worked correctly, plus I'm looking at
the XML file now, and it has length 9!
Please tell me why you think the length is showing up as 19 rather
than 9, i.e. why does the function work in-line but not externally?
Note that when I say externally, I mean that I include it in the
<HEAD>, then call the function in a <javascript ...> tag within
<HEAD>.
function importXML(file) {
var xmlDoc;
var moz = (typeof document.implementation != 'undefined') &&
(typeof
document.implementation.createDocument != 'undefined');
var ie = (typeof window.ActiveXObject != 'undefined');
if (moz) {
xhttp=new XMLHttpRequest();
xhttp.open("GET",file,false);
xhttp.send("");
xmlDoc=xhttp.responseXML;
} else if (ie) {
xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
xmlDoc.async = false;
while(xmlDoc.readyState != 4) {};
xmlDoc.load(file);
}
return xmlDoc;
}
function importXML(file) {
var xmlDoc;
var moz = (typeof document.implementation != 'undefined') &&
(typeof
document.implementation.createDocument != 'undefined');
var ie = (typeof window.ActiveXObject != 'undefined');
if (moz) {
xhttp=new XMLHttpRequest();
xhttp.open("GET",file,false);
xhttp.send("");
xmlDoc=xhttp.responseXML;
} else if (ie) {
xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
xmlDoc.async = false;
while(xmlDoc.readyState != 4) {};
xmlDoc.load(file);
}
return xmlDoc;
}
Thank you,
Kevin
Meet importXML (see below). It merely imports an XML file to the
object, "xmlDoc."
When I call this function in-line, i.e. when I include the whole
importXML.js in the <HEAD>, I can access the XML elements sucessfully.
However, when I call this function externally, i.e. I include it in
the <HEAD> as a <javascript src = ".../importXML.js>, it fails to
work. It fails because alerts tell me that a sample XML file has a
length of 19, when in fact it has a length of 9. I confidently say
that it's 9 because the function worked correctly, plus I'm looking at
the XML file now, and it has length 9!
Please tell me why you think the length is showing up as 19 rather
than 9, i.e. why does the function work in-line but not externally?
Note that when I say externally, I mean that I include it in the
<HEAD>, then call the function in a <javascript ...> tag within
<HEAD>.
function importXML(file) {
var xmlDoc;
var moz = (typeof document.implementation != 'undefined') &&
(typeof
document.implementation.createDocument != 'undefined');
var ie = (typeof window.ActiveXObject != 'undefined');
if (moz) {
xhttp=new XMLHttpRequest();
xhttp.open("GET",file,false);
xhttp.send("");
xmlDoc=xhttp.responseXML;
} else if (ie) {
xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
xmlDoc.async = false;
while(xmlDoc.readyState != 4) {};
xmlDoc.load(file);
}
return xmlDoc;
}
function importXML(file) {
var xmlDoc;
var moz = (typeof document.implementation != 'undefined') &&
(typeof
document.implementation.createDocument != 'undefined');
var ie = (typeof window.ActiveXObject != 'undefined');
if (moz) {
xhttp=new XMLHttpRequest();
xhttp.open("GET",file,false);
xhttp.send("");
xmlDoc=xhttp.responseXML;
} else if (ie) {
xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
xmlDoc.async = false;
while(xmlDoc.readyState != 4) {};
xmlDoc.load(file);
}
return xmlDoc;
}
Thank you,
Kevin