How do I choose the “News” category from “section” in the following xml sample starting with:
$(feed).find('section').each(function () {
And:
<?xml version="1.0" encoding="ISO-8859-1"?>
<feed>
<section category="News">
<title>Recent News</title>
<article>
<headline lang="en">News headline here</headline>
<url>#</url>
</article>
</section>
<section category="Blog">
<title>Recent Blogs</title>
<article>
<headline lang="en">Recent blog headline here</headline>
<url>#</url>
</article>
</section>
</feed>
Also, how do I choose just the first 5 articles?
$(this).find('article').each(function () {
var headline = $(this).find('headline').text();
var url = $(this).find('url').text();
html += '<li><a href="' + url + '">' + headline + '</a></li>';
});
$(feed).find('section[category="News"]').each(...$(this).find('article').slice(0,5).each(...