Hi,
I'm new in this forum.
I was searching for a solution to read xml file with javascript in Firefox (I hate this browser...grrrr r...) and I've found this topic.
I've read all but my problem still exist! :-(
I report what I've wrote. The original script I've made is more complicated but the problem is the same, so I've tried with a smaller page. That's the source:
[code=javascript]<html>
<head>
<script type="text/javascript">
var xml;
function test(){
// Load XML Explorer
if(window.Activ eXObject){
xml = new ActiveXObject(" Microsoft.XMLDO M");
xml.async = false;
xml.load("casa. xml");
var prova = xml.selectSingl eNode("prodotti/prodotto/codice[text() = 0001]");
var nome = prova.parentNod e.selectSingleN ode("titolo").t ext;alert(nome) ;
}
else{
if(document.imp lementation && document.implem entation.create Document){
xml = window.document .implementation .createDocument ("","",null) ;
var caricamento = xml.load("casa. xml");
xml.onload = readXML;
//alert(xmlFile);
}
}
}
function readXML(){
var toTry = xml.getElements ByTagName("prod otti")[0].childNodes[0].nodeValue;
alert(toTry); // Result Empty Alert
}
</script>
</head>
<body onload="test()" >
<div id="test">
</div>
</body>
</html>[/code]
I was trying to read from an XML file. In IE I have no problems, but Firefox don't want to read...
Some one coult help me or I have to carry Firefox to Primary School to learn how to read???
Thank you (and sorry for my English...I'm Italian...).
Giordan.
I'm new in this forum.
I was searching for a solution to read xml file with javascript in Firefox (I hate this browser...grrrr r...) and I've found this topic.
I've read all but my problem still exist! :-(
I report what I've wrote. The original script I've made is more complicated but the problem is the same, so I've tried with a smaller page. That's the source:
[code=javascript]<html>
<head>
<script type="text/javascript">
var xml;
function test(){
// Load XML Explorer
if(window.Activ eXObject){
xml = new ActiveXObject(" Microsoft.XMLDO M");
xml.async = false;
xml.load("casa. xml");
var prova = xml.selectSingl eNode("prodotti/prodotto/codice[text() = 0001]");
var nome = prova.parentNod e.selectSingleN ode("titolo").t ext;alert(nome) ;
}
else{
if(document.imp lementation && document.implem entation.create Document){
xml = window.document .implementation .createDocument ("","",null) ;
var caricamento = xml.load("casa. xml");
xml.onload = readXML;
//alert(xmlFile);
}
}
}
function readXML(){
var toTry = xml.getElements ByTagName("prod otti")[0].childNodes[0].nodeValue;
alert(toTry); // Result Empty Alert
}
</script>
</head>
<body onload="test()" >
<div id="test">
</div>
</body>
</html>[/code]
I was trying to read from an XML file. In IE I have no problems, but Firefox don't want to read...
Some one coult help me or I have to carry Firefox to Primary School to learn how to read???
Thank you (and sorry for my English...I'm Italian...).
Giordan.
Comment