XML Problem in FireFox

wxdqz

New Member
Hi all,

I have a very basic xml file that has some customer names in it, like this:


<?xml version="1.0" encoding="ISO-8859-1" standalone="yes"?>
<!DOCTYPE customers [
<!ELEMENT customers (customer+)>
<!ELEMENT customer (name)>
<!ELEMENT name (#PCDATA)>
]>
<customers>
<customer>
<name>Jon Doe</name>
</customer>
<customer>
<name>Jane Doe</name>
</customer>
</customers>


And I have a basic script file that opens the xml doc and gets the customer names:


function getxmldoc() {
if (window.ActiveXObject) {
doc = new ActiveXObject("Microsoft.XMLDOM");
doc.async = false;
doc.load("customers.xml");
getnames();
} else {
doc = document.implementation.createDocument("","",null);
doc.load("customers.xml");
doc.onload = getnames;
}
}
function getnames() {
var names = doc.getElementsByTagName("name");
alert(names.length);
document.close();
}


The code works beautifully in IE7 and alerts '2' but Firefox (v2.0) alerts '0'

Why is this happening?
 
Back
Top