JS读取XML文件,这个有错吗?谢谢!
一、HTML文件<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN"
"http://www.
<html>
<head>
</head>
<body>
<div id="jia"></div>
<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","wenjian.xml",false);
xmlhttp.send();
xmlDoc=xmlhttp.responseXML;
document.getElementById("jia").innerHTML=
xmlDoc.getElementsByTagName("tou")[0].childNodes[0].nodeValue;
</script>
</body>
</html>
二、XML文件
<?xml version="1.0" encoding="UTF-8"?>
<tou>
<jian>我是一只小小鸟</jian>
<jian2>我是一只小小鸟2</jian2>
<jian3>我是一只小小鸟3</jian3>
<jian4>我是一只小小鸟4</jian4>
</tou>
三、有问题么?何解?