With the help of this newsgroup and Google I have got this code
working fully in Firefox and can alert the XML in IE but because IE
does not impliment the DOM "getElementsByT agNameNS()" function I
cannot read the individual rates from the Cube namespace.
Is there a wrapper or some other relatively simple method of getting
IE to do what in Firefox is straighforward?
Here is the code. Any help gratefully received.
var doc
function load() {
if (document.imple mentation &&
document.implem entation.create Document){
doc = document.implem entation.create Document("", "", null);
doc.load('CEBra tes.xml');
doc.onload = createTable;
}
else if (window.ActiveX Object){
var doc1 = new ActiveXObject(" Microsoft.XMLDO M");
function loadXML(xmlFile ){
doc1.async="fal se";
doc1.onreadysta techange=verify ;
doc1.load(xmlFi le);
doc=doc1.docume ntElement;
}
loadXML('CEBrat es.xml');
alert(doc.xml)
}
else {
alert('Your browser can\'t handle this script');
return;
}
}
function verify() {
if (doc1.readyStat e != 4 ){
return false;
}
}
function createTable() {
var cubes = doc.getElements ByTagNameNS('ht tp://www.ecb.int/
vocabulary/2002-08-01/eurofxref','Cub e');
var dateRate = cubes[1].getAttribute(' time');
var dateRateSplit = dateRate.split( '-');
for (var i = 2; i < cubes.length; i++){
var currency = cubes[i].getAttribute(' currency');
var rate = cubes[i].getAttribute(' rate');
rateObject[currency] = rate;
}
document.getEle mentById('boldS tuff').innerHTM L = dateRateSplit[2]
+ "." + dateRateSplit[1] + "." + dateRateSplit[0];
document.getEle mentById("curre ncy").value = "GBP";
getRates();
};
var rateObject = {};
function getRates() {
var curr= document.getEle mentById("curre ncy").value;
var currRate = rateObject[curr];
var currStatement= "1 EUR = " + currRate + " " + curr ;
document.getEle mentById("rate" ).value=currSta tement;
var currRev=1/currRate;
currRevFix=curr Rev.toFixed(5);
var currRevStatemen t= "1 " + curr +"= " + currRevFix + " EUR";
document.getEle mentById("rateR ev").value=curr RevStatement;
};
working fully in Firefox and can alert the XML in IE but because IE
does not impliment the DOM "getElementsByT agNameNS()" function I
cannot read the individual rates from the Cube namespace.
Is there a wrapper or some other relatively simple method of getting
IE to do what in Firefox is straighforward?
Here is the code. Any help gratefully received.
var doc
function load() {
if (document.imple mentation &&
document.implem entation.create Document){
doc = document.implem entation.create Document("", "", null);
doc.load('CEBra tes.xml');
doc.onload = createTable;
}
else if (window.ActiveX Object){
var doc1 = new ActiveXObject(" Microsoft.XMLDO M");
function loadXML(xmlFile ){
doc1.async="fal se";
doc1.onreadysta techange=verify ;
doc1.load(xmlFi le);
doc=doc1.docume ntElement;
}
loadXML('CEBrat es.xml');
alert(doc.xml)
}
else {
alert('Your browser can\'t handle this script');
return;
}
}
function verify() {
if (doc1.readyStat e != 4 ){
return false;
}
}
function createTable() {
var cubes = doc.getElements ByTagNameNS('ht tp://www.ecb.int/
vocabulary/2002-08-01/eurofxref','Cub e');
var dateRate = cubes[1].getAttribute(' time');
var dateRateSplit = dateRate.split( '-');
for (var i = 2; i < cubes.length; i++){
var currency = cubes[i].getAttribute(' currency');
var rate = cubes[i].getAttribute(' rate');
rateObject[currency] = rate;
}
document.getEle mentById('boldS tuff').innerHTM L = dateRateSplit[2]
+ "." + dateRateSplit[1] + "." + dateRateSplit[0];
document.getEle mentById("curre ncy").value = "GBP";
getRates();
};
var rateObject = {};
function getRates() {
var curr= document.getEle mentById("curre ncy").value;
var currRate = rateObject[curr];
var currStatement= "1 EUR = " + currRate + " " + curr ;
document.getEle mentById("rate" ).value=currSta tement;
var currRev=1/currRate;
currRevFix=curr Rev.toFixed(5);
var currRevStatemen t= "1 " + curr +"= " + currRevFix + " EUR";
document.getEle mentById("rateR ev").value=curr RevStatement;
};
Comment