Martin Honnen wrote:
Andrew Poulos wrote:
If I do something like the following snippet in JS:
xFile = "test.xml";
xDoc = document.implementation.createDocument("", "theXdoc", null);
xDoc.load(xFile);
// there's a pause here then
var data = xDoc.getElementsByTagName("text1")[0];
It works locally in IE6 and MZ1 but doesn't work when I upload the
files MZ1 tells me that 'data' has no properties. What is it that I'm
doing wrong?
Loading is done asynchronously so you need an onload event handler (for
Mozilla) and an onreadystate event handler for IE.
I tried re-writing it to something like this for MZ:
<script type="text/javascript">
xmlDoc = "undefined";
function initXML(xmlFile) {
if (document.implementation&&document.implementation. createDocument) {
xmlDoc = document.implementation.createDocument("","doc",nu ll);
if (typeof xmlDoc != "undefined") {
xmlDoc.load(xmlFile);
xmlDoc.onload = stuffToDo;
}
}
}
function stuffToDo() {
alert(xmlDoc.getElementsByTagName("messages")[0]);
var msgobj = xmlDoc.getElementsByTagName("messages")[0];
// more stuff here...
}
</script>
<BODY onload="initXML('test.xml');">
The alert fires, so I think the xml file is being loaded, but it
displays the value as 'undefined'. It works locally so I'm at a loss as
to why it doesn't work when I post the files. Any help appreciated.
Andrew Poulos