有道手机归属地返回的XML不会解析

hdjdjdjd 发布于 2012/11/05 16:47
阅读 351
收藏 0

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>归属地</title>
</head>




<body>


<p>
<b>号码:</b> <input type="text" id="input" name="input" value="187******39"><br />
<input type="button"  onclick="fan()" value="查询"><br />
<b>号码:</b> <span id="num"></span><br />
<b>地区:</b> <span id="lon"></span>
</p>


<script type="text/javascript">
function fan()
{
if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  }
else
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
  var url="http://www.youdao.com/smartresult-xml/search.s?type=mobile&q="+document.getElementById("input").value;
xmlhttp.open("GET",url,false);
xmlhttp.send();
xmlDoc=xmlhttp.responseXML;




document.getElementById("num").innerHTML=
xmlDoc.getElementsByTagName("phonenum")[0].childNodes[0].nodeValue;


document.getElementById("lon").innerHTML=
xmlDoc.getElementsByTagName("location")[0].childNodes[0].nodeValue;}
</script>
</body>
</html>

 

加载中
0
hdjdjdjd
hdjdjdjd
我感到没有错误,就是不对
返回顶部
顶部