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

来源:互联网 发布:nodejs 数据接口开发 编辑:程序博客网 时间:2024/06/06 05:18
 <?xml version="1.0" encoding="utf-8" ?>  <bookstore>   <book>   <title>Rain</title>   <year>2010</year>   <author>Martin</author>   </book>  <book>   <title>Cloud</title>  <year>2009</year>  <author>Robert</author> </book>  <book>  <title>River</title>  <year>2007</year>  <author>Fred</author>  </book>  </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());                 });    });});


原创粉丝点击