JavaScript AND XML: can't open javascipt in html?

sadik

New Member
I tried to compile in chrome but Nothing displayed only subject offered. I really do not know what is the problem. I'd checked my code thrice and thrice .. but something is really wrong. I'm using notepad++. subject.html\[code\]<html><body><h1 align="center">Subjects Offered</h1><br><br><br><script type="text/javascript"> 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","subject.xml",false); xmlhttp.send(); xmlDoc=xmlhttp.responseXML; var x = xmlDoc.getElementsByTagName("subject"); document.write("<table border='5' width=500 height=400 align='center' bordercolor='red'>"); for(i=0;i<x.length;i++) { document.write("<tr>"); document.write("<td align='center'>">; document.write(x.getElementsByTagName("code")[0].childNodes[0].nodeValue); document.write("</td>"); document.write("<td>"); document.write(x.getElementsByTagName("description")[0].childNodes[0].nodeValue); document.write("</td>"); document.write("<td>"); document.write(x.getElementsByTagName("units")[0].childNodes[0].nodeValue); document.write("</td>"); document.write("</tr>"); } document.write("</table>"); </script></body></html>\[/code\]subject.xml\[code\]<open_subjects> <subject> <code>CSSDO2</code> <description>Computer Programming 5</description> <units>3</units> </subject> <subject> <code>CSCI10B</code> <description>Principles of Operating System</description> <units>4</units> </subject> <subject> <code>ITNA04</code> <description>Linux Administration/</description> <units>3</units> </subject> <subject> <code>MATH09</code> <description>Numerical Methods</description> <units>3</units> </subject></open_subjects>\[/code\]
 
Back
Top