jQuery的filter过滤重复结构的xml数据

时间:13-07-19 栏目:JQUERY 作者:zongyan86 评论:0 点击: 3,780 次

1 <?xml version="1.0" encoding="utf-8" ?> 
2 <bookstore>  
3 <book>  
4 <title>Rain</title>  
5 <year>2010</year>  
6 <author>Martin</author>  
7 </book> 
8 <book>  
9 <title>Cloud</title> 
10 <year>2009</year> 
11 <author>Robert</author>
12 </book> 
13 <book> 
14 <title>River</title> 
15 <year>2007</year> 
16 <author>Fred</author> 
17 </book> 
18 </bookstore>
$(document).ready(function () {
    $.get("xmlData/Categories.xml", function (xml) {
                   $(xml).find("book").filter( function (index) {
                        return "Rain" == $(this).find("title").text();
                    }
                   ).each( function (index) {
                        alert($(this).find("author").text());
                 });
    });
});
web开发分享 


声明: 本文由( zongyan86 )原创编译,转载请保留链接: jQuery的filter过滤重复结构的xml数据

关注我们