I'm new in this forum.
I was searching for a solution to read xml file with javascript in Firefox (I hate this browser...grrrrr...) 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:
Expand|Select|Wrap|Line Numbers
- <html>
- <head>
- <script type="text/javascript">
- var xml;
- function test(){
- // Load XML Explorer
- if(window.ActiveXObject){
- xml = new ActiveXObject("Microsoft.XMLDOM");
- xml.async = false;
- xml.load("casa.xml");
- var prova = xml.selectSingleNode("prodotti/prodotto/codice[text() = 0001]");
- var nome = prova.parentNode.selectSingleNode("titolo").text;alert(nome);
- }
- else{
- if(document.implementation && document.implementation.createDocument){
- xml = window.document.implementation.createDocument("","",null);
- var caricamento = xml.load("casa.xml");
- xml.onload = readXML;
- //alert(xmlFile);
- }
- }
- }
- function readXML(){
- var toTry = xml.getElementsByTagName("prodotti")[0].childNodes[0].nodeValue;
- alert(toTry); // Result Empty Alert
- }
- </script>
- </head>
- <body onload="test()">
- <div id="test">
- </div>
- </body>
- </html>
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.