Thursday, 3 December 2015

XML : retrieve ALL rss feeds given a URL - php and javascript

What I am trying to do is given a RSS Feed URL, retrieve the total number of articles since the feed was first created. For example, if you go to www.inoreader.com and paste this URL,http://rss.nytimes.com/services/xml/rss/nyt/HomePage.xml, you will be able to find the total number of articles for that feed.

I have tried a couple of things. One of them was using the following implementation shown in: W3Schools

The problem is that I can only get the first few articles using that implementation. Somehow, RSS Readers like inoreader, are able to get the history for a RSS Feeds. Could someone guide me so that I can get this feature implemented?

The following code, for instance, returns only the first few articles.

  <?php    $xml=('http://rss.nytimes.com/services/xml/rss/nyt/HomePage.xml');    $xmlDoc = new DOMDocument();    $xmlDoc->load($xml);    $x = $xmlDoc->getElementsByTagName('item');    echo $x->length;    ?>    

No comments:

Post a Comment