jquery 读取xml

     <script type="text/javascript" src="jquery/jquery-1.11.3.min.js"></script>
<script type="text/javascript">
//var url = "http://www.w3school.com.cn/example/xmle/simple.xml";
var url = "xml.xml"
var breakfast_menu =new Array();
var food = {};
$(function () {
$("#readXML").click(function(){
$.get(url,function(data){
var xmlData = $(data);
xmlData.find("food").each(function(i){
food.name = $(this).children("name").text();
food.price = $(this).children("price").text();
food.description = $(this).children("description").text();
food.calories = $(this).children("calories").text();
$("#disply").append(food.name + "\n");
// breakfast_menu.push(food);
})
});
/* for(var i = 0;i<breakfast_menu.length;i++){
$("#disply").append(breakfast_menu[i].name + "\n");
}*/
})
})
</script>
上一篇:分割一个表到多个实体


下一篇:Linux下Find命令的使用