Hello,
I wrote a Javascript function that loads a xml file to access the
data. After the loading of the xml file, the function init() is called
(for testing purposes im only returning the number of elements)
The loading executes ok for IE and the init() function returns the
correct numbers of elements.
When i try to load the xml file in Firefox, the init() function
executes but the number of elements is always 0. I guess is because
Firefox can't read the xml correctly. But why?
I've try rewriting the code in all the ways possible with no success.
What's wrong with this simple?
Need help
Marco
function loadXML()
{
//For firefox and friends
if (document.imple mentation && document.implem entation.create Document)
{
alert('my name is Firefox');
xmlDoc = document.implem entation.create Document("", "", null);
xmlDoc.onload = init();
}
else if (window.ActiveX Object)
{
alert('my name is IE');
xmlDoc = new ActiveXObject(" Microsoft.XMLDO M");
xmlDoc.onreadys tatechange = function () {
if (xmlDoc.readySt ate == 4)
{
try { init(); }
catch(e) {alert('Error loading the XML file: ' + e.toString()); }
}};
} //end if
else
{
alert('i have no name :(');
alert('Your browser can\'t load the XML file: ' + e.toString());
return;
} //end else if
xmlDoc.load("DB/discography_ori ginal.xml");
}
function init()
{
...
var cdElems = xmlDoc.getEleme ntsByTagName('c d');
alert('# of CDs: ' + cdElems.length) ;
...
} 8 14499
I have a book that covers JavaScript and a little bit of XML. It says
that accessing XML with JavaScript _only_ works in Internet Explorer
5.0+ for Windows.
One generally uses PHP to access XML, because PHP is implemented on
the server and therefor consistent.
Book's Website: http://www.webbedenvironments.com/dh...ss%5Fadvanced/
SM wrote:
xmlDoc = document.implem entation.create Document("", "", null);
xmlDoc.onload = init();
That line needs to be
xmlDoc.onload = init;
--
Martin Honnen http://JavaScript.FAQTs.com/
On May 22, 7:41 am, Martin Honnen <mahotr...@yaho o.dewrote:
SM wrote:
xmlDoc = document.implem entation.create Document("", "", null);
xmlDoc.onload = init();
That line needs to be
xmlDoc.onload = init;
--
Martin Honnen http://JavaScript.FAQTs.com/
that last one did it for me.
xmldoc.onload = init; WORKS fine
but
xmldoc.onload = init(parameters ) doesn't work!
how do i pass a value in the init function?
thanks marco
SM wrote:
xmldoc.onload = init; WORKS fine
but
xmldoc.onload = init(parameters ) doesn't work!
how do i pass a value in the init function?
xmldoc.onload = function (evt) {
init(value);
};
--
Martin Honnen http://JavaScript.FAQTs.com/
Zabac wrote:
I have a book that covers JavaScript and a little bit of XML. It says
that accessing XML with JavaScript _only_ works in Internet Explorer
5.0+ for Windows.
One generally uses PHP to access XML, because PHP is implemented on
the server and therefor consistent.
Book's Website: http://www.webbedenvironments.com/dh...ss%5Fadvanced/
Then the book would be wrong, which should tell you a great deal about
the rest of the book. For instance, this question was answered and fixed
in a post after yours.
On May 22, 8:40 am, Martin Honnen <mahotr...@yaho o.dewrote:
SM wrote:
xmldoc.onload = init; WORKS fine
but
xmldoc.onload = init(parameters ) doesn't work!
how do i pass a value in the init function?
xmldoc.onload = function (evt) {
init(value);
};
--
Martin Honnen http://JavaScript.FAQTs.com/
Works like a charm! Thanks Martin
Although, im not sure what the evt means in function(evt). If its not
to much to ask, could you explain.
I wrote the function with and without the 'evt', and they both work
ok....just wondering
ie
xmldoc.onload = function(evt) { init(value); };
xmldoc.onload = function() { init(value); };
Thanks
Marco
SM wrote:
Although, im not sure what the evt means in function(evt). If its not
to much to ask, could you explain.
Event handlers like onload have an event object argument that allows you
to check properties of the event. If you don't need that argument then
you can code
xmldoc.onload = function () {
init(value);
};
--
Martin Honnen http://JavaScript.FAQTs.com/ This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: urs |
last post by:
Two days ago, I built an ASP.NET 2.0 application and published it on a
shared IIS 6 Web server. After publishing, and during the whole day, it
worked fine.
The server remained untouched since. Today, I wanted to access the home
page of the application again with a browser. But instead of the proper
page, I just got an ugly message:
Server Error in '/' Application.
|
by: yehaimanish |
last post by:
I am developing an application by which to parse the content from the
access_log and insert it into the database. Since each row is an
different entry, I am using file() to get the contents into an array
and manipulate each row by foreach(...) and insert/update in the
database accordingly.
If the file is small, it works well. If the file is large (say > 5mb),
it generates memory allocation error. However I came to know that the
allowed...
|
by: mathewda |
last post by:
Hey, I'm having a problem that I consider kinda weird that is alluding
me at the moment. I've wrote some code that will set up an
XMLHttpRequest, it then makes a call to open and send and sets the
onreadystatechange to another function of mine. onreadystatechange
checks the ready state and if the ready state is 4 and the status is
200 it assigns to the innerHTML of a div. I also have some code that
uses the attachEvent method so that all...
|
by: iamaporkaholic |
last post by:
The main page of the site has this script which determines the
language settings of the OS. This works fine for IE but not for
firefox. Is there any other codes which i have to insert to make sure
Firefox would be able to load it?
<script type="text/javascript">
function detectlang()
{
var lang=navigator.userLanguage
var langs=navigator.systemLanguage
|
by: robudo |
last post by:
Hello,
I need some help to solve the following problem. I wrote some html/javascript code to read data from an XML file:
XML file:
<places>
<place year="2000" name="Amsterdam" />
<place year="2000" name="Amstelveen" />
</places>
html/javascript code:
| |
by: fran_j_diaz |
last post by:
Hi,
I've got some web pages whiches are too heavy. My pages have TabPanels
and I saw that it was possible to load a tabPanel when we click in
instead of the page loading.
I went to
http://blogs.msdn.com/sburke/archive/2007/06/13/how-to-make-tab-control-panels-load-on-demand.aspx
|
by: dolittle |
last post by:
Hi,
I`m using dynamic script tags to dynamically load scripts from a remote server and it works well.
I`m simulating a network issue by disconnecting from the network and reconnecting. Then I`m trying to load scripts again.
On FireBug I can see that the browser gets the correct response from the server but the scripts aren`t being excuted.
On IE7 it works fine.
Is this a know issue with firefox?
|
by: Denis |
last post by:
Hello,
Maybe somebody already solved this task. I need to load JS
asynchronously without blocking browser. This means that I do not need
to block browser to load/render during loading script. The simple
construction to do this:
jsJSNode = document.createElement(“script”);
jsJSNode.type = “text/javascript”;
jsJSNode.src = “http:// den-01/Default.aspx“;
document.body.appendChild(jsMyNode);
|
by: Hush |
last post by:
Hi,
The following code works fine in IE7 but FF returns with an error:
Access denied to achieve the property Element.firstChild. In this
line:
nodes = xmlDoc.documentElement.childNodes;
My code:
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| | |