McKee91
02-19-2008, 07:27 PM
Hello, I'm new to coding and I don't know much about the techniques.
I have this code that allows me to import an external XML file and use it in my HTML website. When I view the file on my computer, everything is good, but when I upload my HTML file on the web, the XML data doesn't show up at all.
Am' I missing something?
Here's my code
<html>
<head>
<link rel="stylesheet" type="text/css" href="css.css">
</head>
<body>
<table class='mainrostertable'>
<tr>
<td>
<p class='rosterHeader'>Roster</p>
</td>
</tr>
<tr>
<td>
<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://gamebattles.com/xbox360/call-of-duty-4/team/few-good-men/stats.xml");
var x=xmlDoc.getElementsByTagName("player");
var profilepic="<img src='images/profile.png' border='0'>";
var pic2="<img src='images/approved.png' border='0'>";
document.write("<table bgcolor='444444' cellpadding='5' align='center' class='statsTable'>");
document.write("<thead>");
document.write("<tr><th class='tableHeader'></th><th class='tableHeader'>Member</th><th class='tableHeader'>Role</th><th class='tableHeader'>GB Rank</th><th class='tableHeader'>Member Since</th><th class='tableHeader'>Eligibility</th></tr>");
document.write("</thead>");
for (var i=0;i<x.length;i++)
{
document.write("<tr>");
document.write("<td class='statsRow1'>");
document.write("<p>" + profilepic.link(x[i].getElementsByTagName("url")[0].childNodes[0].nodeValue) + "</p>");
document.write("</td>");
document.write("<td class='rosterRow1'>");
document.write(x[i].getElementsByTagName("name")[0].childNodes[0].nodeValue);
document.write("</td>");
document.write("<td class='rosterRow1'>");
document.write(x[i].getElementsByTagName("role")[0].childNodes[0].nodeValue);
document.write("</td>");
document.write("<td class='statsRow1'>");
document.write(x[i].getElementsByTagName("gbRank")[0].childNodes[0].nodeValue);
document.write("</td>");
document.write("<td class='statsRow1'>");
document.write(x[i].getElementsByTagName("memberSince")[0].childNodes[0].nodeValue);
document.write("</td>");
document.write("<td class='rosterRow2'>");
document.write("<p>" + pic2.link(x[i].getElementsByTagName("url")[0].childNodes[0].nodeValue) + "</p>");
document.write("</td>");
document.write("</tr>");
}
document.write("</table>");
}
</script>
</td>
</tr>
</table>
</body>
</html>
I have this code that allows me to import an external XML file and use it in my HTML website. When I view the file on my computer, everything is good, but when I upload my HTML file on the web, the XML data doesn't show up at all.
Am' I missing something?
Here's my code
<html>
<head>
<link rel="stylesheet" type="text/css" href="css.css">
</head>
<body>
<table class='mainrostertable'>
<tr>
<td>
<p class='rosterHeader'>Roster</p>
</td>
</tr>
<tr>
<td>
<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://gamebattles.com/xbox360/call-of-duty-4/team/few-good-men/stats.xml");
var x=xmlDoc.getElementsByTagName("player");
var profilepic="<img src='images/profile.png' border='0'>";
var pic2="<img src='images/approved.png' border='0'>";
document.write("<table bgcolor='444444' cellpadding='5' align='center' class='statsTable'>");
document.write("<thead>");
document.write("<tr><th class='tableHeader'></th><th class='tableHeader'>Member</th><th class='tableHeader'>Role</th><th class='tableHeader'>GB Rank</th><th class='tableHeader'>Member Since</th><th class='tableHeader'>Eligibility</th></tr>");
document.write("</thead>");
for (var i=0;i<x.length;i++)
{
document.write("<tr>");
document.write("<td class='statsRow1'>");
document.write("<p>" + profilepic.link(x[i].getElementsByTagName("url")[0].childNodes[0].nodeValue) + "</p>");
document.write("</td>");
document.write("<td class='rosterRow1'>");
document.write(x[i].getElementsByTagName("name")[0].childNodes[0].nodeValue);
document.write("</td>");
document.write("<td class='rosterRow1'>");
document.write(x[i].getElementsByTagName("role")[0].childNodes[0].nodeValue);
document.write("</td>");
document.write("<td class='statsRow1'>");
document.write(x[i].getElementsByTagName("gbRank")[0].childNodes[0].nodeValue);
document.write("</td>");
document.write("<td class='statsRow1'>");
document.write(x[i].getElementsByTagName("memberSince")[0].childNodes[0].nodeValue);
document.write("</td>");
document.write("<td class='rosterRow2'>");
document.write("<p>" + pic2.link(x[i].getElementsByTagName("url")[0].childNodes[0].nodeValue) + "</p>");
document.write("</td>");
document.write("</tr>");
}
document.write("</table>");
}
</script>
</td>
</tr>
</table>
</body>
</html>