62,046
社区成员
发帖
与我相关
我的任务
分享
<brands>
<brand>
<brand_id>1</brand_id>
<brand_title>title1</brand_title>
<brand_url>www.1.cn</brand_url>
<brand_content>我们很开心1</brand_content>
<brand_pic>1.jpg</brand_pic>
</brand>
<brand>
<brand_id>2</brand_id>
<brand_title>title2</brand_title>
<brand_url>www.1.cn</brand_url>
<brand_content>我们很开心2</brand_content>
<brand_pic>2.jpg</brand_pic>
</brand>
</brands>
<script type="text/javascript" >
function swaps_on(id) {
jQuery.ajax({
url: "brand.xml",
type: "GET",
dataType: "xml",
success: function (xml) {
.......................
}
});
}
</script>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>无标题页</title>
<script type="text/javascript" src="jquery-1.3.2.min.js"></script>
<script type="text/javascript">
function swaps_on(id){
var node="";
$.ajax({
url:"XMLFile3.xml",
type:"get",
success:function(result){
$(result).find("brand").each(function(){
if($(this).find("brand_id").text()==id){
$(this).children().each(function(){
node+= $(this).text()+"==";
})
}
})
document.write(node);
}
})
}
</script>
</head>
<body>
<a onclick="swaps_on('1')">获取</a>
</body>
</html>
<!--
结果
1==title1==www.1.cn==我们很开心1==1.jpg==
-->