L
littlefool
Hi,
I'm trying to access a XML file in Firefox. It works perfect in IE
(with the ActiveXObject), but in Firefox displays it an empty page. I
found on the web examples how to do that, but I still have problems
with it. Can anyone help me with this?
This is the XML-file
<?xml version="1.0" encoding="UTF-8"?>
<constituencyseats>
<seat>
<Region>Central Scotland</Region>
<Constituency>Aidrie and Shotts</Constituency>
<Party>Labour</Party>
</seat>
<seat>
<Region>Central Scotland</Region>
<Constituency>Coatbridge and Chryston</Constituency>
<Party>Labour</Party>
</seat>
</constituencyseats>
This is the the code
this.xmlObj = loadXMLSeats('scripts/xml/Constituencyseats.xml',
'seat');
function loadXMLSeats(xmlFile, tagname){
var xmlDoc;
if(document.implementation && document.implementation.createDocument)
{
xmlDoc = document.implementation.createDocument("", "", null);
}
else if (window.ActiveXObject) {
xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
xmlDoc.async="false";
xmlDoc.onreadystatechange=verify;
}
else {
alert('your browser can\'t handle this script');
return;
}
xmlDoc.load(xmlFile);
return xmlDoc.getElementsByTagName(tagname);
}
function verify(){
// 0 Object is not initialized
// 1 Loading object is loading data
// 2 Loaded object has loaded data
// 3 data from object can be worked with
// 4 Object completely initialized
if (xmlDoc.readyState != 4) return false;
}
It appears that in Firefox the problem occurs with loading the XML
file. After loading, the object stays empty.
Thank you for your help
I'm trying to access a XML file in Firefox. It works perfect in IE
(with the ActiveXObject), but in Firefox displays it an empty page. I
found on the web examples how to do that, but I still have problems
with it. Can anyone help me with this?
This is the XML-file
<?xml version="1.0" encoding="UTF-8"?>
<constituencyseats>
<seat>
<Region>Central Scotland</Region>
<Constituency>Aidrie and Shotts</Constituency>
<Party>Labour</Party>
</seat>
<seat>
<Region>Central Scotland</Region>
<Constituency>Coatbridge and Chryston</Constituency>
<Party>Labour</Party>
</seat>
</constituencyseats>
This is the the code
this.xmlObj = loadXMLSeats('scripts/xml/Constituencyseats.xml',
'seat');
function loadXMLSeats(xmlFile, tagname){
var xmlDoc;
if(document.implementation && document.implementation.createDocument)
{
xmlDoc = document.implementation.createDocument("", "", null);
}
else if (window.ActiveXObject) {
xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
xmlDoc.async="false";
xmlDoc.onreadystatechange=verify;
}
else {
alert('your browser can\'t handle this script');
return;
}
xmlDoc.load(xmlFile);
return xmlDoc.getElementsByTagName(tagname);
}
function verify(){
// 0 Object is not initialized
// 1 Loading object is loading data
// 2 Loaded object has loaded data
// 3 data from object can be worked with
// 4 Object completely initialized
if (xmlDoc.readyState != 4) return false;
}
It appears that in Firefox the problem occurs with loading the XML
file. After loading, the object stays empty.
Thank you for your help