473,387 Members | 1,899 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

XML access voor Firefox

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

Nov 23 '05 #1
1 1400


littlefool wrote:

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.
Look here for suggestions on how to to that:
<http://www.faqts.com/knowledge_base/view.phtml/aid/6826/fid/616>

var xmlDoc;
if(document.implementation && document.implementation.createDocument)
{
xmlDoc = document.implementation.createDocument("", "", null);
}
There are more browsers than Mozilla that support the above but a load
method is only exposed by some Mozilla versions thus that call
xmlDoc.load(xmlFile);


will give an error in Opera for instance.

As for the Mozilla problem loading by default happens asynchronously so
you would need to set up an onload handler before calling the load
method. Or in newer Mozilla versions you can do synchronous loading by
setting
xmlDoc.async = false
before calling the load method. But synchronous loading blocks the
browser so it might be fine for a first test to play with XML, in your
final code on the web you should use asynchronous loading.

But check the article I linked to above, it is not necessary and helpful
to go the createDocument/load way for Mozilla as it does not work in
other browser at all while XMLHttpRequest to load XML works in lots of
browsers by now and gives you more possibilities and better error
handling (e.g. access to HTTP headers).

--

Martin Honnen
http://JavaScript.FAQTs.com/
Nov 23 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: DD | last post by:
Hello, Could anyone please help me?? Is there somebody who could explain me how to make a connection to a access database with a python cgi script. I would like to use common sql commands in my...
1
by: Pim van der Eijk | last post by:
XML 2004 Award voor ''Best Powered XML Site'' De XML gebruikersgroep geeft traditioneel aan het eind van het jaar tijdens het jaarlijkse congres een award aan de persoon of het initiatief die in...
7
by: Rensjuh | last post by:
Hello, does someone have / know a good C++ tutorial for beginnners? I would prefer Dutch, but English is also fine. Hoi, heeft / kent iemand nog een goede C++ tutorial voor beginners? Het liefste...
2
by: Ronny Sigo | last post by:
Hello all, I am trying to send email via Access. When performing this below routine the program stops at what I called the P R O B L E M L I N E. I have Microsoft Outlook as the default...
1
by: DD | last post by:
Hello, Could anyone please help me?? Is there somebody who could explain me how to make a connection to a access database with a python cgi script. I would like to use common sql commands in my...
5
by: RO|_F | last post by:
Hello, Does anybody know if there are programs which do the following: Act as 'front end' of a database (preferrably MS Access) Encrypts or converts the contents of the database so that data is...
1
by: GielO | last post by:
Beste Access cracks, Wie van jullie kan mij helpen hoe een koppeling te maken tussen een pin/chip automaat (zoals gebruikt in winkels en warenhuizen) en een op access en/of VBA gebaseerd Kassa...
1
by: =?Utf-8?B?RXZlcnQ=?= | last post by:
Sinds enige tijd heb ik op onze NT4 pc's en server een hardnekkig virus, malware of spyware zitten. Het begon met het starten van een bestand dirx9.exe genaamd door een sleutel in de registry...
1
by: Flupke | last post by:
Hello everyone, I'm trying to make a OLEDB-connection between VB.Net (Visuel Studio 2005) and an Access-2003 database. This works smoothly and without a single problem on a Windows XP desktop...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.