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.
 
         
                                         
                                         
                                         
                                        ![Interactive visualization of a graph in python [closed]](https://www.devze.com/res/2023/04-10/09/92d32fe8c0d22fb96bd6f6e8b7d1f457.gif) 
                                         
                                         
                                         
                                         加载中,请稍侯......
 加载中,请稍侯......
      
精彩评论