开发者

Rss feeds: get certain amount of tweets

开发者 https://www.devze.com 2023-02-28 03:08 出处:网络
Is it possible to giv开发者_开发百科e a parameter when getting the RSS feeds to determine how many feeds it should get?

Is it possible to giv开发者_开发百科e a parameter when getting the RSS feeds to determine how many feeds it should get?

I don't want to load all the RSS feeds, but only the first 20. Is this possible?

Thanks!


You can set the limit. By executing a Loop in limit. So it will parse the xml and your program will read items in loop. Once the loop crossed the limit. Just break the loop.

$i=0;
while ($reader->read()) {

if($i>=10)
       break;
else{
switch ($reader->nodeType) {

case (XMLREADER::ELEMENT):

if ($reader->localName == "item") {

$node = $reader->expand();

$dom = new DomDocument();

$n = $dom->importNode($node,true);

$dom->appendChild($n);                           

$sxe = simplexml_import_dom($n);

$url = (String)$sxe->url;
$title=(String)$sxe->title;
}

}
}

In the above code $i is the limiter. Where we can limit number feed to display in the page.

0

精彩评论

暂无评论...
验证码 换一张
取 消