EDN Admin
Well-known member
I have an XML document entitled "CD_Catalog.Xml" the contents of which I am trying display as an HTML document. When I use Internet Explorer 8 to open the HTML document that contains Javascript to display the contents, I get a blank page.
XML File:
<?xml version="1.0" encoding="ISO-8859-1" ?> <br/>
- <!-- Edited by XMLSpy® <br/>
--> <br/>
- <CATALOG><br/>
- <CD><br/>
<TITLE>Empire Burlesque</TITLE> <br/>
<ARTIST>Bob Dylan</ARTIST> <br/>
<COUNTRY>USA</COUNTRY> <br/>
<COMPANY>Columbia</COMPANY> <br/>
<PRICE>10.90</PRICE> <br/>
<YEAR>1985</YEAR> <br/>
</CD><br/>
- <CD><br/>
<TITLE>Hide your heart</TITLE> <br/>
<ARTIST>Bonnie Tyler</ARTIST> <br/>
<COUNTRY>UK</COUNTRY> <br/>
<COMPANY>CBS Records</COMPANY> <br/>
<PRICE>9.90</PRICE> <br/>
<YEAR>1988</YEAR> <br/>
</CD><br/>
</CATALOG>
HTML document:
<html><br/>
<body>
<script type="text/javascript <br/>
if (window.XMLHttpRequest)<br/>
{// code for IE7+, Firefox, Chrome, Opera, Safari<br/>
xmlhttp=new XMLHttpRequest();<br/>
}<br/>
else<br/>
{// code for IE6, IE5<br/>
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");<br/>
}<br/>
xmlhttp.open("GET","cd_catalog.xml",false);<br/>
xmlhttp.send();<br/>
xmlDoc=xmlhttp.responseXML;
document.write("<table border=1>");<br/>
var x=xmlDoc.getElementsByTagName("CD");<br/>
for (i=0;i<x.length;i++)<br/>
{ <br/>
document.write("<tr><td>");<br/>
document.write(x.getElementsByTagName("ARTIST")[0].childNodes[0].nodeValue);<br/>
document.write("</td><td>");<br/>
document.write(x.getElementsByTagName("TITLE")[0].childNodes[0].nodeValue);<br/>
document.write("</td></tr>");<br/>
}<br/>
document.write("</table>");<br/>
</script>
</body><br/>
</html>
Not sure whats up...
John
View the full article
XML File:
<?xml version="1.0" encoding="ISO-8859-1" ?> <br/>
- <!-- Edited by XMLSpy® <br/>
--> <br/>
- <CATALOG><br/>
- <CD><br/>
<TITLE>Empire Burlesque</TITLE> <br/>
<ARTIST>Bob Dylan</ARTIST> <br/>
<COUNTRY>USA</COUNTRY> <br/>
<COMPANY>Columbia</COMPANY> <br/>
<PRICE>10.90</PRICE> <br/>
<YEAR>1985</YEAR> <br/>
</CD><br/>
- <CD><br/>
<TITLE>Hide your heart</TITLE> <br/>
<ARTIST>Bonnie Tyler</ARTIST> <br/>
<COUNTRY>UK</COUNTRY> <br/>
<COMPANY>CBS Records</COMPANY> <br/>
<PRICE>9.90</PRICE> <br/>
<YEAR>1988</YEAR> <br/>
</CD><br/>
</CATALOG>
HTML document:
<html><br/>
<body>
<script type="text/javascript <br/>
if (window.XMLHttpRequest)<br/>
{// code for IE7+, Firefox, Chrome, Opera, Safari<br/>
xmlhttp=new XMLHttpRequest();<br/>
}<br/>
else<br/>
{// code for IE6, IE5<br/>
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");<br/>
}<br/>
xmlhttp.open("GET","cd_catalog.xml",false);<br/>
xmlhttp.send();<br/>
xmlDoc=xmlhttp.responseXML;
document.write("<table border=1>");<br/>
var x=xmlDoc.getElementsByTagName("CD");<br/>
for (i=0;i<x.length;i++)<br/>
{ <br/>
document.write("<tr><td>");<br/>
document.write(x.getElementsByTagName("ARTIST")[0].childNodes[0].nodeValue);<br/>
document.write("</td><td>");<br/>
document.write(x.getElementsByTagName("TITLE")[0].childNodes[0].nodeValue);<br/>
document.write("</td></tr>");<br/>
}<br/>
document.write("</table>");<br/>
</script>
</body><br/>
</html>
Not sure whats up...
John
View the full article