Parse custom tags from RSS/XML using SimplePie
I've just installed SimplePie to parse my RSS feeds to display on my site. I've tried their tutorial for grabbing custom XML tags, but things aren't working out.
The custom tag is: < odat:ima开发者_开发百科ge>http://www.image.com/images/items/image.jpg< /odat:image>
I want to breakdown the tags into different variables so I can format the display of the information anyway I'd like. Any ideas?
Thank you!
Current SimplePie code:
foreach ($feed->get_items() as $item):?>
<div class="item">
<h2><a href="<?php echo $item->get_permalink(); ?>"><?php echo $item->get_title(); ?></a></h2>
<p><small>Posted on <?php echo $item->get_date('j F Y | g:i a'); ?></small></p>
</div>
<?php endforeach;?>
try
$items = $feed->get_items();
foreach ($items as $item):?>
<div class="item">
<h2><a href="<?php echo $item->get_permalink(); ?>"><?php echo $item->get_title(); ?></a></h2>
<p><small>Posted on <?php echo $item->get_date('j F Y | g:i a'); ?></small></p>
</div>
<?php endforeach;?>
This should fix your problem
To get at the custom element within the feed you can use get_item_tags()
an array of tags will be returned
http://simplepie.org/wiki/reference/simplepie_item/get_item_tags
if you inspect the array using print_r() you should be able to find the data you need and how to access it
Dc
精彩评论