Parsing Specific Sub category of RSS Feed using JQM
I've parsed the following RSS (http://timesofindia.indiatimes.com/rss.cms) in this way-
My code-
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>News Parser</title>
<script src="http://code.jquery.com/jquery-1.11.0.min.js"></script>
<link rel="stylesheet" href="css/jquery.mobile-1.4.2.min.css" />
<script src="js/jquery-1.10.2.min.js"></script>
<script src="js/jquery-1.9.1.min.js"></script>
<script src="js/jquery.mobile-1.4.2.min.js"></script>
<script type="text/javascript">
var url1 = "https://www.readability.com/api/content/v1/parser?url=";
var testurl = "http://timesofindia.indiatimes.com/rss.cms";
var urltoken = "&token=18ba7d424a0d65facdaea8defa356bc3e430f8ce";
var finalurl = url1 + testurl + urltoken;
console.debug(finalurl)
$(function()
{
$.ajax(
{
url:finalurl,
dataType: "json",
contentType:"application/json",
success: function (data)
{
console.log(data);
console.log(data.content);
//console.error(JSON.parse(data.content));
$("body").empty().append(data.content);
},
error:function(d)
{
console.log(d);
}
});
});
</script>
<style type="text/css">
p
{
color: green;
}
</style>
</head>
<body>
</body>
</html>
I'm getting the content of RSS Feed like this -
Now i want to parse Specific Sub- Category of RSS Feeds like SPort, Technology etc. How could i do, If im passing the specific url of the sub category, which is **http://timesofindia.feedsportal.com/c/33039/f/533921/index.rss, http://www.thehindu.com/sport/?service=rss ,
I m getting blank window.
Please suggest me how could i parse specific Sub Category of RSS Feeds ?
Sub Category of RSS Feeds
HTML
<!DOCTYPE html>
<html>
<head>
<title>Car</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.4.2/jquery.mobile-1.4.2.min.css">
<script src="http://code.jquery.com/jquery-1.10.2.min.js"></script>
<script src="http://code.jquery.com/mobile/1.4.2/jquery.mobile-1.4.2.min.js"></script>
<meta name="viewport" content="width=device-width, initial-scale=1">
</head>
<body>
<!-- Page 1 -->
<div data-role="page" id="firstPage" >
<div data-role="header">
<h1>Rss Feed</h1>
</div><!-- /header -->
<div role="main" class="ui-content" id="content">
</div><!-- /content -->
</div><!-- /Page End -->
</body>
</html>
JAVASCRIPT
$.ajax({
url:'http://timesofindia.feedsportal.com/c/33039/f/533921/index.rss',
dataType:'xml',
type:'GET',
success:function(xml) {
$(xml).find('item').each(function() {
var title = $(this).find("title").text();
var link = $(this).find("link").text();
var description = $(this).find("description").text();
var pubDate = $(this).find("pubDate").text();
$("#content").append('<div><p><a href="'+link+'">'+title+'</a><p><p>'+pubDate+'<p><p>'+description+'<p><div>');
});
},
error:function() {
alert("Feed error..!");
}
});
$.ajax({
url:'http://www.thehindu.com/sport/?service=rss',
dataType:'xml',
type:'GET',
success:function(xml) {
$(xml).find('item').each(function() {
var title = $(this).find("title").text();
var category = $(this).find("category").text();
var link = $(this).find("link").text();
var description = $(this).find("description").text();
var pubDate = $(this).find("pubDate").text();
$("#content").append('<div><p><a href="'+link+'">'+title+'</a><p><p>'+pubDate+'<p><p>'+description+'<p><div><p>Category: '+category+'<p><div>');
});
},
error:function() {
alert("Feed error..!");
}
});
链接地址: http://www.djcxy.com/p/20940.html
上一篇: 如何从多个数组中删除文件详细信息