0

我试图在 chrome 中编译,但没有显示只提供的主题。我真的不知道是什么问题。我三次又三次地检查了我的代码..但确实出了点问题。我正在使用记事本++。

主题.html

<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[i].getElementsByTagName("code")[0].childNodes[0].nodeValue);
                document.write("</td>");
                document.write("<td>");

            document.write(x[i].getElementsByTagName("description")[0].childNodes[0].nodeValue);
                document.write("</td>");
                document.write("<td>");

            document.write(x[i].getElementsByTagName("units")[0].childNodes[0].nodeValue);
                document.write("</td>");
            document.write("</tr>");
        }

    document.write("</table>");
    </script>
</body>
</html>

主题.xml

<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>
4

1 回答 1

0

第 26 行有一个语法错误:

document.write("<td align='center'>">;

应该

document.write("<td align='center'>");
于 2012-12-11T04:53:57.747 回答