Hi, I'm having problems loading data from an XML file.
It works fine with IE and Safari. It also works fine with Firefox provided I browse the files on my local drive. However, when i upload the files to the server and browse via the internet, Forefox doesn't perform as it should. Has anyone had this problem? Thanks.
It seems to go wrong
after the line:
HeadingTpe = Heading[j].substring(0,1);
Scripts:
// JScript File
Heading = ["?. Incomplete","A. Corporate Strategy","B. Organisational Effectiveness",
"C. Operational Effectiveness","D. Business Tools"];
var xmlFile ='tipFile.xml';
var xmlDoc = null;
var ua = navigator.userAgent.toLowerCase();
if (ua.indexOf('safari/') != -1) { // code for Safari, use XMLHttpRequest() instead of .load()
XmlHTTP = new XMLHttpRequest();
XmlHTTP.open('get', xmlFile, false);
XmlHTTP.send('');
xmlDoc = XmlHTTP.responseXML;}
else if (window.ActiveXObject) { // code for IE
xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
xmlDoc.async = false;
xmlDoc.load(xmlFile);}
else if (document.implementation.createDocument) { // code for Mozilla, Firefox, Opera, etc.
xmlDoc = document.implementation.createDocument('','',null) ;
xmlDoc.async = false;
xmlDoc.load(xmlFile);}
else{
alert('Your browser JavaScript is enabled, but it cannot handle this script');
}
if (xmlDoc != null){
var x = xmlDoc.getElementsByTagName("tip");
for (j=1;j<=4;j++){
document.write('<li>' + Heading[j].substr(3,Heading[j].length) + '<ol class = "L4">');
HeadingTpe = Heading[j].substring(0,1);
for (i=0;i<x.length;i++){
type = x[i].getElementsByTagName('type')[0].firstChild.nodeValue;
file = x[i].getElementsByTagName('file')[0].firstChild.nodeValue;
title = x[i].getElementsByTagName('title')[0].firstChild.nodeValue;
TipDte = file.substring(6,8) + file.substring(9,11);
if (type == HeadingTpe){
document.write('<li><a href = "' + file +'">'+ title + '</a></li>' );
}
}
document.write('</ol></li>');
}
}
/*
--------------------------------------------------------------------------
This is a short version of 'tipFile.xml'
--------------------------------------------------------------------------
<?xml version="1.0" encoding="utf-8" ?>
<dataset>
<tip>
<title>Excel in Electronics - Resistor and Capacitor Marking Codes.</title>
<file>tip_2007_12.html</file><type>D</type></tip>
<tip>
<title>Vision and Mission.</title>
<file>tip_2008_01.html</file><type>A</type></tip>
<tip>
<title>Surrogate Performance Measurements - MSGc and PI.</title>
<file>tip_2008_02.html</file><type>C</type></tip>
<tip>
<title>Field Force Effectiveness.</title>
<file>tip_2008_03.html</file><type>B</type></tip>
</dataset>
--------------------------------------------------------------------------
The HTML file to load the 'ShowXML.js'
--------------------------------------------------------------------------
<!DOCTYPE html PUBLIC "-//W3C//DTD XHML 1.0 Transitional//EN"
"
http://www.w3.org/TR/xhml1/DTD/xhml1-transitional.dtd">
<html xmlns="
http://www.w3.org/1999/xhtml">
<head>
<title>yada yada</title>
</head>
<body>
<h2>
Tips from previous months</h2>
<script language="JavaScript" type="text/javascript" src="ShowXML.js"></script>
</body>
</html>
--------------------------------------------------------------------------
*/