I am parsing yahoo media rss feeds through SimplePie
library.
I had a need to add custom node named <category>
as a child node to <title>
.
Now I need to parse the content of that node every time through the loop...
Here is a structure of my feed
<rss version="2.0" xmlns:media="http://search.yahoo.com/mrss/">
<channel>
.....
.....
<item>
<title></title>
<link></link>
....
<media:content>
...
</media:content>
<category>one</category>
</item>
<item>
<title>...</title>
<link>...</link>
....
<media:content>
...
</media:content>
<category>two</category>
</item>
</channel>
</rss>
My task is to parse the content of the <category>
nodes
I have tried using $item->get_item_tags()
the following way, but no luck, I get null
in return
$cat_get= $item->get_item_tags('http://search.yahoo.com/mrss/',
'item');
$cat_get_node = $category1[0]['child']['http://search.yahoo.com/mrss/']['category'];
$cat_content = $category2[0]['data'];
Any direction will be helpful...
Try this instead, as the element is in the root namespace.
$cat = $item->get_item_tags(SIMPLEPIE_NAMESPACE_RSS20, 'category');
$cat_content = $cat[0]['child'];