473,467 Members | 2,005 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

xml code working in internet explorer only

hi,

i am using the following code which works well in internet explorer
but not in firefox (and perhaps others too):

var xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
xmlDoc.async="false";
xmlDoc.load("xml/names.xml");
nodes = xmlDoc.documentElement.childNodes
span_html = '<p>'
for (var i=0; i<nodes.length; i++) {
name = nodes.item(i).firstChild.text
span_html += 'name: '+name+'<br>';
}
span_html += '</p>';
can anybody tell me another way of writting this so it will work in
other browsers or better yet, so it will work in other browsers and
internet explorer? cheers

burnsy
Jul 23 '05 #1
3 1999
In article <65**************************@posting.google.com >,
bi******@yahoo.co.uk says...
hi,

i am using the following code which works well in internet explorer
but not in firefox (and perhaps others too):


You're using MS extensions to JavaScript.

http://www.sitepoint.com/article/xml-javascript-mozilla

--
Hywel http://kibo.org.uk/
I do not eat quiche.
Jul 23 '05 #2


mr_burns wrote:

i am using the following code which works well in internet explorer
but not in firefox (and perhaps others too):

var xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
That stuff with ActiveXObject is geared towards IE/Win, it doesn't work
with Mozilla or Firefox or Opera, not even with IE/Mac.

If you want to load an XML document with Mozilla or with Opera 7.60
preview or 8.00 beta or with Safari 1.2 then you can use the
XMLHttpRequest object which is modelled after the Microsoft.XMLHTTP
object of MSXML.
Details are here:
<http://www.faqts.com/knowledge_base/view.phtml/aid/17226/fid/616>
<http://jibbering.com/2002/4/httprequest.html>
name = nodes.item(i).firstChild.text


But note that text is not a property in the W3C DOM that Mozilla or
Opera implement, for a text node the nodeValue might give you what you
want, if you are looking at element nodes then you need to write a
function to collect the text of child nodes.
With DOM Level 3 there is the textContent property too, recent Mozilla
versions implement that but not Opera as far as I know.

--

Martin Honnen
http://JavaScript.FAQTs.com/
Jul 23 '05 #3
mr_burns wrote:
i am using the following code which works well in internet explorer
but not in firefox (and perhaps others too):
Definately in others as well. Konqueror for example will do nothing with
this code.
var xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
See those magic words: "ActiveXObject" and "Microsoft"... they are
synonymous. You get ActiveX with Microsoft and Microsot supplies
Microsoft. Firefox isn't Microsoft.
can anybody tell me another way of writting this so it will work in
other browsers or better yet, so it will work in other browsers and
internet explorer? cheers


Yup - you'll find lots of code (try SourceForge) that offers examples.
There are, basically, three standard ways of getting at XML data and the
one you want to use depends on what you want to do with the XML.
Unfortunately, the method you have used is not one of the three.
Jul 23 '05 #4

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

Similar topics

2
by: esrkq | last post by:
Hi, I am looking at a way to return IP related information of a visitor loading a web page and found the following snippet of code: if(navigator.javaEnabled() && (navigator.appName !=...
6
by: bissatch | last post by:
Hi, I have been tryin to run free dhtml code from a web page. The web page is: http://dynamicdrive.com/dynamicindex14/pixelate.htm When I load the page above it opens as normal and the...
10
by: Don Munroe | last post by:
This one has me stumped. I have three web applications running on two different servers. The first that works fine is hosted by a .Net hosting company. Everyone that uses it has no problems...
3
by: Craig Kenisston | last post by:
Hi, This is a silly question. I'm relatively new to asp.net and asp at all. But I always had this doubt. I'm working with Visual Studio and while exploring the ASPCommerce starter kit, when I...
1
by: alphanode | last post by:
When starting up my computer, I am able to open Internet Explorer windows and have them load without a problem, however once I open and run a .net project I am working on, this causes any new IE...
6
by: Sandy | last post by:
Hello - I have a little application that I would like to have an exit button on that closes my web application and closes Internet Explorer. What is the code that will do that? Any help...
9
by: dli07 | last post by:
Hello, I'm trying to convert a piece of code that creates a dynamic vertical resizing bar in a table from internet explorer to firefox. It's based on a post from...
3
by: TS | last post by:
I am using IE 7. I have a website running on my local machine (localhost) and auto complete doesnt work for any of the textboxes, but going to web sites on the internet does support this so i know...
5
by: mukeshrasm | last post by:
Hi I am using AJAX to display the value in selection/list box. this code is working fine in Firefox Mozila browser but it is not working in Internet Explorer so please tell me how this will work...
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
marktang
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,...
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...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
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,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
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...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.