xml文档:
<?xml version="1.0" standalone="yes"?>
<CATALOG>
<HOUSE>
<DISTRICT>yantian</DISTRICT>
<NAME>lanhuahu</NAME>
<DEVELOPER>jinke</DEVELOPER>
<NUMBER>20750</NUMBER>
<HOT>1</HOT>
</HOUSE>
<HOUSE>
<DISTRICT>yantian</DISTRICT>
<NAME>meilanju</NAME>
<DEVELOPER>jinke</DEVELOPER>
<NUMBER>30655</NUMBER>
<HOT>0</HOT>
</HOUSE>
<HOUSE>
<DISTRICT>nanshan</DISTRICT>
<NAME>kekexili</NAME>
<DEVELOPER>longhu</DEVELOPER>
<NUMBER>21590</NUMBER>
<HOT>0</HOT>
</HOUSE>
<HOUSE>
<DISTRICT>nanshan</DISTRICT>
<NAME>gaoshanhuayuan</NAME>
<DEVELOPER>longhu</DEVELOPER>
<NUMBER>26205</NUMBER>
<HOT>1</HOT>
</HOUSE>
<HOUSE>
<DISTRICT>yantian</DISTRICT>
<NAME>fengjingwuxian</NAME>
<DEVELOPER>longhu</DEVELOPER>
<NUMBER>20100</NUMBER>
<HOT>1</HOT>
</HOUSE>
<HOUSE>
<DISTRICT>baoan</DISTRICT>
<NAME>shencaifeiyang</NAME>
<DEVELOPER>longhu</DEVELOPER>
<NUMBER>20400</NUMBER>
<HOT>0</HOT>
</HOUSE>
<HOUSE>
<DISTRICT>yantian</DISTRICT>
<NAME>binfenwuxian</NAME>
<DEVELOPER>yongyou</DEVELOPER>
<NUMBER>20300</NUMBER>
<HOT>0</HOT>
</HOUSE>
</CATALOG>
HTML文档:
<!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=gb2312" />
<title>无标题文档</title>
<script type="text/javascript">
function changPage(url)
{
if(url!= "")
{
window.open("http://"+url);
}
}
function getlist(area,type)
{
var xmlDoc=null;
if(window.ActiveXObject)
{
xmlDoc=new ActiveXObject("Microsoft.XMLDOM");}
else if (document.implementation.createDocument)
{
xmlDoc=document.implementation.createDocument("","",null);
}
else
{
alert('Your browser cannot handle this script');
}if (xmlDoc!=null)
{
xmlDoc.async=false;
xmlDoc.load("catalog.xml");
var x=xmlDoc.getElementsByTagName("HOUSE");
var area;
var type;
document.write("<select name='楼盘名' size='type' onchange=changPage('bbs.szhome.com/'+this.options[this.selectedIndex].value)>");
document.write("<option>--选择--");
for (i=0;i<x.length;i++)
{
if(x[i].getElementsByTagName("DISTRICT")[0].childNodes[0].nodeValue==area)
{
document.write("<option value="+x[i].getElementsByTagName("NUMBER")[0].childNodes[0].nodeValue+">");
document.write(x[i].getElementsByTagName("NAME")[0].childNodes[0].nodeValue);
}
}
document.write("</select>");
}
}</script></head><body>
<script type="text/javascript">getlist("baoan","");
</script>
<br><br>
<script type="text/javascript">getlist("nanshan","");
</script>
<br><br>
<script type="text/javascript">getlist("yantian","");
</script></body>
</html>现在我想把XML数据中的HOT标签为1的NAME显示在下拉列表框的前端,其他的NAME再根据首字母进行排序.
还请多多指教?
<?xml version="1.0" standalone="yes"?>
<CATALOG>
<HOUSE>
<DISTRICT>yantian</DISTRICT>
<NAME>lanhuahu</NAME>
<DEVELOPER>jinke</DEVELOPER>
<NUMBER>20750</NUMBER>
<HOT>1</HOT>
</HOUSE>
<HOUSE>
<DISTRICT>yantian</DISTRICT>
<NAME>meilanju</NAME>
<DEVELOPER>jinke</DEVELOPER>
<NUMBER>30655</NUMBER>
<HOT>0</HOT>
</HOUSE>
<HOUSE>
<DISTRICT>nanshan</DISTRICT>
<NAME>kekexili</NAME>
<DEVELOPER>longhu</DEVELOPER>
<NUMBER>21590</NUMBER>
<HOT>0</HOT>
</HOUSE>
<HOUSE>
<DISTRICT>nanshan</DISTRICT>
<NAME>gaoshanhuayuan</NAME>
<DEVELOPER>longhu</DEVELOPER>
<NUMBER>26205</NUMBER>
<HOT>1</HOT>
</HOUSE>
<HOUSE>
<DISTRICT>yantian</DISTRICT>
<NAME>fengjingwuxian</NAME>
<DEVELOPER>longhu</DEVELOPER>
<NUMBER>20100</NUMBER>
<HOT>1</HOT>
</HOUSE>
<HOUSE>
<DISTRICT>baoan</DISTRICT>
<NAME>shencaifeiyang</NAME>
<DEVELOPER>longhu</DEVELOPER>
<NUMBER>20400</NUMBER>
<HOT>0</HOT>
</HOUSE>
<HOUSE>
<DISTRICT>yantian</DISTRICT>
<NAME>binfenwuxian</NAME>
<DEVELOPER>yongyou</DEVELOPER>
<NUMBER>20300</NUMBER>
<HOT>0</HOT>
</HOUSE>
</CATALOG>
HTML文档:
<!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=gb2312" />
<title>无标题文档</title>
<script type="text/javascript">
function changPage(url)
{
if(url!= "")
{
window.open("http://"+url);
}
}
function getlist(area,type)
{
var xmlDoc=null;
if(window.ActiveXObject)
{
xmlDoc=new ActiveXObject("Microsoft.XMLDOM");}
else if (document.implementation.createDocument)
{
xmlDoc=document.implementation.createDocument("","",null);
}
else
{
alert('Your browser cannot handle this script');
}if (xmlDoc!=null)
{
xmlDoc.async=false;
xmlDoc.load("catalog.xml");
var x=xmlDoc.getElementsByTagName("HOUSE");
var area;
var type;
document.write("<select name='楼盘名' size='type' onchange=changPage('bbs.szhome.com/'+this.options[this.selectedIndex].value)>");
document.write("<option>--选择--");
for (i=0;i<x.length;i++)
{
if(x[i].getElementsByTagName("DISTRICT")[0].childNodes[0].nodeValue==area)
{
document.write("<option value="+x[i].getElementsByTagName("NUMBER")[0].childNodes[0].nodeValue+">");
document.write(x[i].getElementsByTagName("NAME")[0].childNodes[0].nodeValue);
}
}
document.write("</select>");
}
}</script></head><body>
<script type="text/javascript">getlist("baoan","");
</script>
<br><br>
<script type="text/javascript">getlist("nanshan","");
</script>
<br><br>
<script type="text/javascript">getlist("yantian","");
</script></body>
</html>现在我想把XML数据中的HOT标签为1的NAME显示在下拉列表框的前端,其他的NAME再根据首字母进行排序.
还请多多指教?
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货