<script src="jquery-1.11.2.min.js"></script>
</head> <body> <select id="sel">
</select> <script type="text/javascript">
$.ajax({
url:"xmlchuli.php",
dataType:"XML",
success: function(data){
//alert($(data).find("code").eq(1).text());
alert($(data).find("nation").attr("bs")); var allcode = $(data).find("code");
var allname = $(data).find("name");
var str ="";
for(var i=0;i<allcode.length;i++)
{
var code = allcode.eq(i).text();
var name = allname.eq(i).text(); str = str +"<option value='"+code+"'>"+name+"</option>";
} $("#sel").html(str);
}
});
</script>
</body>
处理页面
<?php
include("DBDA.class.php");
$db = new DBDA(); $sql = "select * from nation"; $attr = $db->Query($sql); echo "<nation bs='1'>"; foreach($attr as $k=>$v)
{
echo "<n{$k}><code>{$v[0]}</code><name>{$v[1]}</name></n{$k}>";
} echo "</nation>";