...

View Full Version : Table not showing??



mikebyrne
12-11-2008, 07:56 PM
I'm doing a simple xml for for a wii database and now my table is not appearing on screen??

Here's my code

xmltest.html


<html>
<head>

<script type="text/javascript">
var xmlDoc;
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');
}
xmlDoc.async=false;
xmlDoc.load("file:///C:/Users/Mike/Desktop/wiicat.xml");

var x=xmlDoc.getElementsByTagName("CD");

function show(i)
{
artist=(x[i].getElementsByTagName("ARTIST")[0].childNodes[0].nodeValue);
title=(x[i].getElementsByTagName("TITLE")[0].childNodes[0].nodeValue);
year=(x[i].getElementsByTagName("YEAR")[0].childNodes[0].nodeValue);
country=(x[i].getElementsByTagName("COUNTRY")[0].childNodes[0].nodeValue);
company=(x[i].getElementsByTagName("COMPANY")[0].childNodes[0].nodeValue);
price=(x[i].getElementsByTagName("PRICE")[0].childNodes[0].nodeValue);

txt="Artist: "+artist+"<br />Title: "+title+"<br />Year: "+year+"<br />Country: "+country+"<br />Company: "+company+"<br />Price: "+price ;

document.getElementById("show").innerHTML=txt;
}
</script>
<style type="text/css">
<!--
.style1 {
font-family: "Times New Roman", Times, serif;
font-size: 16px;
color: #003399;
}
body,td,th {
color: #000000;
}
body {
background-color: #FFFFFF;
background-image: url(wii.jpg);
background-repeat: no-repeat;
}
.style3 {
color: #000000;
font-size: xx-large;
}
-->
</style>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"></head>

<body>
<div align="justify"></div>
<div class="style1" id='show'>
<div align="center" class="style3">CLICK ON A ROW TO DISPLAY GAME INFO</div>
</div>
<div align="center"><br />
</div>
<p align="center" class="style1">
<script type="text/javascript">
document.write("<table border='1'>");
for (var i=0;i<x.length;i++)
{
document.write("<tr onclick='show(" + i + ")'>");
document.write("<td>");
document.write(x[i].getElementsByTagName("ARTIST")[0].childNodes[0].nodeValue);
document.write("</td>");

document.write("<td>");
document.write(x[i].getElementsByTagName("TITLE")[0].childNodes[0].nodeValue);
document.write("</td>");
document.write("</tr>");
}
document.write("</table>");
</script>
</p>
</body>
</html>


wiicat.xml



<CATALOG>

<CD>
<TITLE>The Golden Compass</TITLE>
<ARTIST>SEGA</ARTIST>
<COUNTRY>PAL</COUNTRY>
<COMPANY>Sega</COMPANY>
<PRICE>55</PRICE>
<YEAR>2008</YEAR>
</CD>

<CD>
<TITLE>Super Mario Galaxy</TITLE>
<ARTIST>Wii</ARTIST>
<COUNTRY>PAL</COUNTRY>
<COMPANY>Nintendo</COMPANY>
<PRICE>45/PRICE>
<YEAR>2007</YEAR>
</CD>

</CATALOG>


Any help to get my table to appear would be great!

fishluvr
12-11-2008, 09:22 PM
Typo in your XML.

<PRICE>45</PRICE>

mikebyrne
12-12-2008, 12:21 PM
Thanks alot! (It was driving me mental)



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum