grazie ad un tutorial di pro.html
sto provando ad impaginare un file xml.
ma ho un errore di lettura del file js.
il file per la lettura è:
codice:<html> <head> <title>Estrarre dati da un file XML con JavaScript</title> <style type="text/css"> h1 { color: #800000; font-size: 15px; font-family: Verdana; } td { background-color: #FFFFFF; font-size: 12px; font-family: Verdana; } </style> <script language="javascript" for="window" event="onload" src="leggi.js"></script> </head> <body> <xml id="DSO_risultati" src="risultati_now.xml"></xml> <h1 align="center">risultati</h1> <div id="Stampa"></div> </body> </html>
il file js è :
codice:var Mostra = ""; var StringaXml = DSO_risultati.XMLDocument; var i; for (i=0; i<StringaXml.documentElement.childNodes.length; i++) { Mostra += "<table bgcolor='#F9F9F9' align='center' width='450' border='1' bordercolor='#CCCCCC'>" Mostra += "<tr>" Mostra += "<td colspan='2' style='background-color: #008080;'>" Mostra += "<font color='#FFFFFF'>Amico # " + (i + 1) + "</font>" Mostra += "</td>" Mostra += "</tr>" Mostra += "<tr>" Mostra += "<td width='100'>Nome:</td>" Mostra += "<td>" + StringaXml.documentElement.childNodes(i).childNodes(0).text + "</td>" Mostra += "</tr>" Mostra += "<tr>" Mostra += "<td>Cognome:</td>" Mostra += "<td>" + StringaXml.documentElement.childNodes(i).childNodes(1).text + "</td>" Mostra += "</tr>" Mostra += "<tr>" Mostra += "<td>Telefono:</td>" Mostra += "<td>" + StringaXml.documentElement.childNodes(i).childNodes(2).text + "</td>" Mostra += "</tr>" Mostra += "<tr>" Mostra += "<td>Indirizzo:</td>" Mostra += "<td>" + StringaXml.documentElement.childNodes(i).childNodes(3).text + "</td>" Mostra += "</tr>" Mostra += "<tr>" Mostra += "<td>Città:</td>" Mostra += "<td>" + StringaXml.documentElement.childNodes(i).childNodes(4).text + "</td>" Mostra += "</tr>" Mostra += "</table>" Mostra += " "; } Stampa.innerHTML = Mostra;
l'errore è:
Errore: DSO_risultati is not defined
File sorgente: mio_sito/leggi.js
Riga: 1