Jonnyabc 0 Report post Posted May 18, 2010 Can't seem to figure out this small problem, so I thought I'd send it out to kS to see what I'm not thinking of. Here are the steps I have taken thus far: Created an RSS feedDesigned a multipurpose feed reader that will pull data from the RSS feedUsing load() and getElementsByTagName("item") to pull in the dataPart of the reader's parameters are the number of rows to display There's only one problem...when there are no results to display, it comes up with an error. The simple solution should be to either determine if the first value for the array exists or is blank. Either way, I can't seem to get the array correct no matter how much I try. I've attempted count() and sizeof(), but both return "1", and the error only arises after I try to read from the array using the getElementsByTagName(), so both are a "big help". Maybe it's late...maybe I'm not thinking straight. Whatever the case, I needed to get connected with you guys again since the shoutbox (or its replacement) is not back online yet. I'm pasting the code and error below: 2 $rssFile = new DOMDocument();3 $rssFile->load("./rss/?id=" . $feedID);45 //get and output "<item>" elements6 $item=$rssFile->getElementsByTagName("item");7 $y=0;8 if($feedCount>count($item)+1) $feedCount = count($item)+1;9 if(isset($item->item(0)->getElementsByTagName('title')->item(0)->childNodes->item(0)->nodeValue))10 {11 for ($i=$feedStart-1; $i<=$feedCount-1; $i++)12 {15 $item_title=$item->item($i)->getElementsByTagName('title')->item(0)->childNodes->item(0)->nodeValue;16 $item_link=$item->item($i)->getElementsByTagName('link')->item(0)->childNodes->item(0)->nodeValue;17 $item_desc=$item->item($i)->getElementsByTagName('description')->item(0)->childNodes->item(0)->nodeValue; Fatal error: Cannot use object of type DOMNodeList as array in C:\wamp\www\jl-ectronics\resources\php\feedreader01.php on line 9 Share this post Link to post Share on other sites
Jonnyabc 0 Report post Posted May 18, 2010 Nevermind...I found the $item->length parameter after a lot of searching. Share this post Link to post Share on other sites