473,549 Members | 2,753 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Problems loading a local XML file with a local webpage

5 New Member

I have designed a webpage mainly consisting in JavaScript code. It has to load an XML document's content when it is loaded so as to show a content depending on the XML data.

Both the HTML file and the XML file have to be stored locally on the computer and not on a server.

I only test in Internet Explorer, and the behaviour is very strange: on some machines, the XML file in well loaded, on some machines it isn't. I haven't seen this problem happening on IE6 and sometimes it happens on IE7, sometimes not... It happens under IE7 on my Vista Virtual Machine, It does not appear on my XP with IE6 and it does appear sometimes on XP with IE7 and sometimes not..
Here is the beginning of the function I use:

Expand|Select|Wrap|Line Numbers
  1. function loadFromXML()
  2. {
  3.     try
  4.     {
  5.         var request = null;
  6.         var xmlDoc = null;
  8.         if (window.XMLHttpRequest) 
  9.         {
  10.             request = new XMLHttpRequest();
  11.                }
  13.         else if (window.ActiveXObject) 
  14.         {
  15.                      request = new ActiveXObject("Microsoft.XMLHTTP");
  16.                }
  18.                if (request) 
  19.         {
  20.             request.open("GET", "commentsDatas.xml"); 
  21.             request.onreadystatechange = function() 
  22.         {
  23.                  if (request.readyState == 4) 
  24.         {                                
  25.                     xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
  26.             xmlDoc.loadXML(request.responseText);
  27.             var commentsList =    xmlDoc.getElementsByTagName("myComment");

If someone has an idea... I suspect that some security policy aspect is at stake but...
Thanks in advance!
Sep 18 '07 #1
7 9077
5,390 Recognized Expert Moderator Expert
moved from js-articles section to js-forum ...
Sep 18 '07 #2
16,027 Recognized Expert Moderator MVP
Why use Ajax for reading the XML file?
Sep 19 '07 #3
5 New Member
What would you suggest instead?
Sep 19 '07 #4
1,351 Recognized Expert Top Contributor
What would you suggest instead?
read this Tutorial to find out how.

good luck
Sep 19 '07 #5
4 New Member
read this Tutorial to find out how.

good luck
That Link fails....might have been interesting too!
Sep 21 '07 #6
16,027 Recognized Expert Moderator MVP
That Link fails....might have been interesting too!
Are you sure? It works fine for me? Maybe the website was temporarily unavailable.
Sep 21 '07 #7
5 New Member
I'm going to have a look at this and I'll come back to tell if it fitted my needs.
Sep 21 '07 #8

Sign in to post your reply or Sign up for a free account.

Similar topics

by: will | last post by:
Trying to modify some code from : http://www.faqts.com/knowledge_base/view.phtml/aid/2357 But having some problems. Cant work out how/why its not adding rows in the right place. seems strange to me. Im trying to get the NS code working first since that appears to be a bit harder to figure out.. heres my code.....
by: Dave | last post by:
Hello, all! I'm having a small problem displaying an ordinary GIF file on my web site. It's just a banner with a transparent background. When I have Norton Internet Security disabled, it displays fine. When I enable Internet Security, the GIF disappears when I refresh the page - it doesn't even show an image placeholder. (Test was run with...
by: Jim Heavey | last post by:
Hello, I have a fairly simple application which reads none to many input files and edits them and if they are clean, it writes these transaction to the database. Any errors it finds, it opens and error file and writes the error message and the error transaction to this file. After the processing of the file is complete, it will copy the...
by: blackhawk | last post by:
I need to build a web page that has to potentially display a large amount of data in two grids on the same page. The HTML file with all of the formatting is about 7MB in size. This is too large and I need to implement some kind of "client side" lazy loading. What I mean is this: I want to display a grid that only shows, say, 20 records....
by: wylbur37 | last post by:
I'm running an Apache server on my own computer (Windows XP Pro). I wrote a simple PHP script (called test3.php) that I'm running by putting the following URL in the address bar of the browser (Firefox) .... http://localhost/test3.php The script generates the following link using the echo statement ...
by: linearfusion | last post by:
Hello, I may not have worded the subject correctly, but what I am trying to do is pull the XML data from the following stream, http://www.360voice.com/api/blog-getentries.asp?tag=changeagent&num=5, into a webpage. What I would like to do, or think I need to do is create a webpage that will pull the XML data from the above URL and write it...
by: CSTechie | last post by:
I've been battling to install PEAR on Windows XP now for too long. I am not sure what I need to do. When I run go-pear.php from the command line, I get the error message as shown at the end. I included everything in case there is something there that's helpful. I'm trying to install PEAR so that I can use PHPUnit. Thanks for the...
by: TuftyTrue | last post by:
Hi, On my site the user can browse to an image with <input type=file etc>. Althrough I have no problem swapping images with: document.getElementById('PictureToDisplay').src = URLtoPictureOnWebServer.src; I cant get it to work with:
by: kevin.a.sweeney | last post by:
I would like to open an application from a hyperlink on a webpage. 1. the webpage is located on my local machine. 2. the application is located on my local machine. 3. the application will run on my local machine. In other words... The WEB is really not involved. What I have so far works with a Netscape Browser but what I really need...
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...
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
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...
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...
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...
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...

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.