<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body>
<select id="province" name="province">
<option value="">请选择</option>
<option value="吉林省">吉林省</option>
<option value="辽宁省">辽宁省</option>
<option value="山东省">山东省</option>
</select>
<select id="city" name="city">
<option value="">请选择</option>
</select>
</body>
<script type="text/javascript">
//跨浏览器解析Xml
function LoadXml(filename){
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",filename,false);
xmlhttp.send();
xmlDoc=xmlhttp.responseXML;
//alert(xmlDoc.getElementsByTagName("city")[1].childNodes[0].nodeValue);
return xmlDoc;
}
/* xmlDoc=LoadXml("city.xml");
alert(xmlDoc.getElementsByTagName("city")[1].childNodes[0].nodeValue);*/
window.onload=function(){
document.getElementById("province").onchange=function(){
//alert(this.value);
var xmlDoc=LoadXml("city.xml");
var ProvinceElement=xmlDoc.getElementsByTagName("province");
alert(ProvinceElement.length);
}
}
</script>
</html>