Parsing RSS2 in PHP

I am trying to get content from an RSS2 feed from one of my sites and use it on another site.

The channel is here . And the code I'm using is taken from this nice site and has been modified as follows:

$doc = new DOMDocument(); $doc->load('http://tripleax.com/john/?feed=rss2'); $arrFeeds = array(); foreach ($doc->getElementsByTagName('item') as $node) { print('<div style="width:100%" class="option"><strong>'); $a = $node->getElementsByTagName('title')->item(0)->nodeValue; print("$a"); print('</strong><br /><span class="option">'); $a = $node->getElementsByTagName('description')->item(0)->nodeValue; print("$a");` } 

The problem I encountered is to show the entire contents of the message. And the description is a kind of teaser. Changing $node->getElementsByTagName('description')->item(0)->nodeValue to $node->getElementsByTagName('content')->item(0)->nodeValue gives nothing, and content:encoded not better .

Can someone point me in the right direction to solve this?

Thanks!

+4
source share
2 answers

You need getElementsByTagNameNS ()

+2
source

Stupid you! Use $node->getElementsByTagName('encoded')->item(0)->nodeValue !

+3
source

Source: https://habr.com/ru/post/1305562/


All Articles