С кодом ниже я показываю названия многих RSS.Эти RSS должны быть в формате rss->channel->item
, где в item
вы найдете title
, description
, pubDate
и т. Д.
Мой вопрос заключается в том, как изменить это, так что также будет принимать RSS в формате feed->entry
, где в entry
вы выводите title
, content
, published
?
$feeds = array('', '');
// Get all feed entries
$posts = array();
foreach ($feeds as $feed) {
$xml = simplexml_load_file($feed);
$posts = array_merge($posts, $xml->xpath('/rss/channel//item'));
}
// Sort feed entries by pubDate (ascending)
usort($posts, 'mysort');
function mysort($x, $y) {
return strtotime($y->pubDate) - strtotime($x->pubDate);
}
foreach ($posts as $post) {
echo $post->description; // if the rss is in the format of rss->channel->item
echo $post->content; // if the rss is in the format of feed->entry->content then
}