Not PHP I Know...but....
Can anybody point out to me why the code below is failing to render the xml file here http://www.ecb.europa.eu/stats/eurofxre ... -daily.xml or alternatively point me to a simple php solution to consume the xml file http://www.ecb.europa.eu/stats/eurofxre ... -daily.xml and render it to a HTML table on a web page? I know its simple but its 11pm here! I'm just getting a blank page with the code below.
I just need a simple table with the currency and corresponding rate rendered in a html table. Appreciate the code below is js, not php. I'm open to a php solution!
thnx very much
Code: Select all
<html>
<body>
<script type="text/javascript">
var xmlDoc=null;
if (window.ActiveXObject)
{// code for IE
xmlDoc=new ActiveXObject("Microsoft.XMLDOM");
}
else if (document.implementation.createDocument)
{// code for Mozilla, Firefox, Opera, etc.
xmlDoc=document.implementation.createDocument("","",null);
}
else
{
alert('Your browser cannot handle this script');
}
if (xmlDoc!=null)
{
xmlDoc.async=false;
xmlDoc.load("http://www.ecb.europa.eu/stats/eurofxref/eurofxref-daily.xml");
document.write("<table border='1'>");
var x=xmlDoc.getElementsByTagName("Cube");
for (i=0;i<x.length;i++)
{
document.write("<tr>");
document.write("<td>");
document.write(
x[i].getElementsByTagName("rate")[0].childNodes[0].nodeValue);
document.write("</td>");
document.write("<td>");
document.write(
x[i].getElementsByTagName("currency")[0].childNodes[0].nodeValue);
document.write("</td>");
document.write("</tr>");
}
document.write("</table>");
}
</script>
</body>
</html>