Click to See Complete Forum and Search --> : Please help- displaying xml


Patty5
10-23-2008, 09:45 AM
I have asked for help previously, with no reply. I'm hoping someone can help with what I feel a simple problem.

I have an xml file called cd_catalog.xml

<?xml version="1.0" encoding="ISO-8859-1" ?>

- <CATALOG>
- <CD>
<TITLE>Empire Burlesque</TITLE>
<ARTIST>Bob Dylan</ARTIST>
<COUNTRY>USA</COUNTRY>
<COMPANY>Columbia</COMPANY>
<PRICE>10.90</PRICE>
<YEAR>1985</YEAR>
</CD>
- <CD>
<TITLE>Hide your heart</TITLE>
<ARTIST>Bonnie Tyler</ARTIST>
<COUNTRY>UK</COUNTRY>
<COMPANY>CBS Records</COMPANY>
<PRICE>9.90</PRICE>
<YEAR>1988</YEAR>
</CD>
</CATALOG>


and I wan't to disply it with this 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("cd_catalog.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>
</head>

<body>
<div id='show'>
Click on one of the table rows to display the full album information.
</div>
<br />
<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><strong>");
document.write(x[i].getElementsByTagName("ARTIST")[0].childNodes[0].nodeValue);
document.write("</strong></td><tr>");

document.write("<tr><td colspan='2'>");
document.write(x[i].getElementsByTagName("TITLE")[0].childNodes[0].nodeValue);
document.write("</td>");
document.write("</tr>");
}
document.write("</table>");
</script>

</body>
</html>


Why isn't any of the xml displaying on the webpage?