2
我正在加載xml文件和nodeValue函數返回undefined,但我不知道爲什麼。這裏是我的XML file。nodeValue return null
var xhttp=new XMLHttpRequest();
xhttp.onreadystatechange = function(){
if(this.readyState===4 && this.status===200){
loadXML(this);
}
};
xhttp.open("GET","XML/shikaku.xml",true);
xhttp.send();
function loadXML(xml){
var xmlDoc= xml.responseXML;
var helpArray=[];
var width,height;
width=xmlDoc.getElementsByTagName("games")[0].getElementsByTagName("game")[0].getElementsByTagName("playground")[0].getElementsByTagName("width")[0].nodeValue;
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<script src="helpik.js"></script>
</head>
<body>
</body>
</html>