Retrieving RSS feed with tag

后端 未结 5 1742
北恋
北恋 2020-12-05 17:58

I have the following snippet of code:

function getFeed($feed_url) {

$content = file_get_contents($feed_url);
$x = new SimpleXmlElement($content);

echo \"&l         


        
5条回答
  •  死守一世寂寞
    2020-12-05 18:32

    The Tag name here is "encoded". Try this:

    $url = 'put_your_feed_URL';
    
        $rss = new DOMDocument();
        $rss->load($url);
        $feed = array();
        foreach ($rss->getElementsByTagName('item') as $node) {
            $item = array (
                    'title' => $node->getElementsByTagName('title')->item(0)->nodeValue,
                    'link' => $node->getElementsByTagName('link')->item(0)->nodeValue,
                    'pubDate' => $node->getElementsByTagName('pubDate')->item(0)->nodeValue,
                    'description' => $node->getElementsByTagName('description')->item(0)->nodeValue,
                    'content' => $node->getElementsByTagName('encoded')->item(0)->nodeValue
    
                    );
            array_push($feed, $item);
        }
    

提交回复
热议问题