Quantcast
Channel: How to parse category term from Wordpress ATOM feed in PHP? - Stack Overflow
Viewing all articles
Browse latest Browse all 2

How to parse category term from Wordpress ATOM feed in PHP?

$
0
0

I have a standard ATOM feed from a Wordpress instance. In the feed, the following category items appear:

<category scheme="http://alpha-s2new.simplescienceinc.com/blog" term="Blog" /><category scheme="http://alpha-s2new.simplescienceinc.com/blog" term="Mobile" /><category scheme="http://alpha-s2new.simplescienceinc.com/blog" term="Websites" />

I'm using the following code to parse the feed:

foreach ($rss->getElementsByTagName('entry') as $node) {    $item = array('title' => $node->getElementsByTagName('title')->item(0)->nodeValue,'desc' => $node->getElementsByTagName('content')->item(0)->nodeValue,'link' => $node->getElementsByTagName('link')->item(0)->nodeValue,'date' => $node->getElementsByTagName('updated')->item(0)->nodeValue,'author' => $node->getElementsByTagName('name')->item(0)->nodeValue,'postid' => $node->getElementsByTagName('id')->item(0)->nodeValue,'cats' => $node->getElementsByTagName('category')->item(0)->nodeValue    );    array_push($feed, $item);}

As you can see.. the last item pulls the "category" node. But it returns an empty string. And I think I know why. So the question is.. what's the syntax to actually pull the terms?


Viewing all articles
Browse latest Browse all 2

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>