mrduclaw
mrduclaw

Reputation: 4035

Parsing RSS2 In PHP

I'm trying to get content from an RSS2 feed from one of my sites and use it in another site.

The feed is here. And the code I'm using is taken from this nice site and has been modified like the following:

$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'm having is, I want to display the entire post's contents. And the description is a sort of the teaser. Changing $node->getElementsByTagName('description')->item(0)->nodeValue to $node->getElementsByTagName('content')->item(0)->nodeValue gives me nothing, and content:encoded is no better.

Can someone please point me in the right direction to solving this?

Thanks!

Upvotes: 4

Views: 1462

Answers (2)

rkulla
rkulla

Reputation: 2524

You need getElementsByTagNameNS()

Upvotes: 2

mrduclaw
mrduclaw

Reputation: 4035

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

Upvotes: 3

Related Questions