0

クロムでコンパイルしようとしましたが、提供された件名のみが表示されませんでした。何が問題なのか本当にわかりません。コードを何度もチェックしましたが、何かが本当に間違っています。私はメモ帳++を使用しています。

subject.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>

subject.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 に答える