I have a html document, which creates a table with data, provided by a xml archive. In the live preview of adobe brackets, i can see the page and the data.
But, when i try to open in some browser, like IE, Firefox or Chrome, the page shows up, just in blank.
Here it's part of the code of the html, and below, code of the xml.
this is the html code
<!DOCTYPE html>
<html>
<head>
<style>
table { border-collapse: collapse; font-family: Futura, Arial, sans-serif; border: 1px solid #777; }
caption { font-size: larger; margin: 1em auto; }
th, td { padding: .65em; }
th, thead { background: #000; color: #fff; border: 1px solid #000; }
tr:nth-child(odd) { background: #ccc; }
tr:hover { background: #aaa; }
td { border-right: 1px solid #777; }
</style>
</head>
<body>
<script>
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.open("GET","prueba_new.xml",false);
xmlhttp.send();
xmlDoc=xmlhttp.responseXML;
document.write("<table><tr><th>CardN</th><th>CardC</th><th>CardE</th><th>CardNe</th></tr>");
var x=xmlDoc.getElementsByTagName("CCard");
for (i=0;i<x.length;i++)
{
document.write("<tr><td>");
document.write(x[i].getElementsByTagName("CardN")[0].childNodes[0].nodeValue);
document.write("</td><td>");
document.write(x[i].getElementsByTagName("CardC")[0].childNodes[0].nodeValue);
document.write("</td><td>");
document.write(x[i].getElementsByTagName("CardE")[0].childNodes[0].nodeValue);
document.write("</td><td>");
document.write(x[i].getElementsByTagName("CardNe")[0].childNodes[0].nodeValue);
document.write("</td></tr>");
}
document.write("</table>");
</script>
</body>
</html>
Here is the xml code, of course, the actual xml file, contains a several hundreds of entries.
<?xml version="1.0"?>
<numbers>
<CCard>
<CardNe>Volkervun</CardNe>
<CardN>10000034999</CardN>
<CardC>Red Team</CardC>
<CardE>Volker.vcd</CardE>
</CCard>
<CCard>
<CardNe>Lady Mars</CardNe>
<CardN>10009899899</CardN>
<CardC>Blue Team</CardC>
<CardE>LadyM.vcd</CardE>
</CCard>
</numbers>
I try several things, but none of them works. Some idea for that blank page?
No comments:
Post a Comment