1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68: 69: 70: 71: 72: 73: 74: 75: 76: 77: 78: 79: 80: 81: 82: 83: 84: 85: 86: 87: 88: 89: 90: 91: 92: 93: 94: 95: 96: 97: 98:
<?php
function RSS_Tags($item, $type) {
$y = array();
$y["type"] = $type;
$tnl = $item->getElementsByTagName("title");
$tnl = $tnl->item(0);
if (is_object($tnl->firstChild)) {
$y["title"] = $tnl->firstChild->textContent;
} else {
$y["title"] = '';
}
$tnl = $item->getElementsByTagName("link");
$tnl = $tnl->item(0);
if (is_object($tnl->firstChild)) {
$link = $tnl->firstChild->textContent;
$y["link"] = $link;
} else {
$y["link"] = '';
}
$tnl = $item->getElementsByTagName("description");
$tnl = $tnl->item(0);
if (is_object($tnl->firstChild)) {
$y["description"] = $tnl->firstChild->textContent;
} else {
$y["description"] = '';
}
$tnl = $item->getElementsByTagName("pubDate");
$tnl = $tnl->item(0);
if (is_object($tnl->firstChild)) {
$y["pubDate"] = $tnl->firstChild->textContent;
} else {
$y["pubDate"] = '';
}
return $y;
}
function RSS_Channel($channel) {
$RSS_Content = array();
$items = $channel->getElementsByTagName("item");
$y = RSS_Tags($channel, 0);
array_push($RSS_Content, $y);
foreach($items as $item) {
$y = RSS_Tags($item, 1);
array_push($RSS_Content, $y);
}
return $RSS_Content;
}
function RSS_Retrieve($url) {
$RSS_Content = array();
$doc = new DOMDocument();
if (@$doc->load($url)) {
$channels = $doc->getElementsByTagName("channel");
foreach($channels as $channel) {
$RSS_Content = array_merge($RSS_Content, RSS_Channel($channel));
}
return $RSS_Content;
} else {
return NULL;
}
}
?>