代码似乎在.responseXML之后就停止了。 xmlDoc为null

时间:2014-10-15 06:23:51

标签: javascript html xml

<!DOCTYPE html>
<body>
<script>
    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","docu.xml",false);
    xmlhttp.send();
    xmlDoc=xmlhttp.responseXML; 
    { 

        // This is where my alert indicates that xmlDoc = null
        // then nothing else happens below.

        document.getElementById("stuff")=xmlDoc.getElementsByTagName("details")
        [0].childNodes[0].nodeValue);
    }
</script>
<input type="text" name="stuff" id="stuff"/>
</body>
</html>

以下是存储在根目录中的DOCU.XML

<?xml=version '1.0'?>
<root>
<details>xml data does not appear</details>
</root>

0 个答案:

没有答案