Forum Moderators: coopster

Message Too Old, No Replies

Problem parsing RSS feed with PHP

         

j_uprichard

3:24 pm on May 7, 2008 (gmt 0)

10+ Year Member



I'm using the PHP/PEAR XML_RSS library to parse a feed on a small website. I have used the following script, (which works perfectly when placed in the website's root directory).

Code:

<?php
error_reporting(E_ALL);
require_once "/...path-to-pear.../pear/PEAR/XML/RSS.php";

$rss =& new XML_RSS("http://www.rte.ie/rss/gaa.xml");
$rss->parse();

// print headlines
print_r($rss->getItems());

echo "<ul>\n";

foreach ($rss->getItems() as $item) {
echo "<li><a href=\"" . $item['link'] . "\">" . $item['title'] . "</a></li>\n";
}

echo "</ul>\n";

?>

However, when i "include" this script into a page within a folder, it doesn't work. Printing the parsed feed simply shows a blank array. Any ideas why this would work in the root directory but not in a folder?

eelixduppy

8:09 pm on May 7, 2008 (gmt 0)




require_once "/...path-to-pear.../pear/PEAR/XML/RSS.php";

Make sure this is the correct path. That is the only thing that I can see going wrong here. Fix that path because that's probably where the error lies.