function fetchFeed($url)
{
// returns items array with sub fields:
// author, link, title, content
$xml = file_get_contents($url);
$xml = str_replace("xmlns='http://www.w3.org/2005/Atom'", '', $xml);
$xml = str_replace('', '', $xml);
$xml = str_replace('', '', $xml);
$xml = str_replace('', '', $xml);
$xml = str_replace('', '', $xml);
$xml = str_replace('- ', '', $xml);
$xml = str_replace('
', '', $xml);
if ( strpos($xml, '', '', $xml);
$xml = str_replace('', '', $xml);
$xml = str_replace('', '', $xml);
$xml = str_replace(' xmlns="http://www.w3.org/2005/Atom" xmlns:openSearch="http://a9.com/-/spec/opensearchrss/1.0/" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0"', ' ', $xml);
$xml = str_replace(' xmlns="http://www.w3.org/2005/Atom" xmlns:openSearch="http://a9.com/-/spec/opensearchrss/1.0/"', ' ', $xml);
$xml = str_replace('loadXML($xml);
$xpath = new domxpath($dom);
$nodes = $xpath->query('//entry');
$items = array();
$i = 0;
foreach ($nodes as $node) {
$items[$i]['title'] = getSubNodeData($xpath, $node, 'title');
$subNodes = $xpath->query('link[@rel="alternate"][1]', $node);
if ( $subNodes->item(0) ) {
$items[$i]['link'] = $subNodes->item(0)->getAttribute('href');
}
if ($items[$i]['link'] == '') {
$items[$i]['link'] = getSubNodeData($xpath, $node, 'link');
}
$items[$i]['content'] = getSubNodeData($xpath, $node, 'content');
$items[$i]['author'] = getSubNodeData($xpath, $node, 'author/name');
$i++;
}
return $items;
}
function getSubNodeData($xpath, $node, $name)
{
$s = '';
$nodes = $xpath->query('.//' . $name . '[1]', $node);
foreach ($nodes as $node) {
$s = $node->firstChild->data;
break;
}
return $s;
}
?>