SimplePie 1.5 is now available!

SimplePie Documentation.  Learn how to use this thing.  It's way better than going to school.

You are here: Documentation » API Reference » SimplePie_Item » get_item_tags()

get_item_tags()

Description

class SimplePie_Item {
	get_item_tags ( string $namespace, string $tag )
}

This method allows you to get access to ANY element/attribute that is a sub-element of the item/entry tag. It will return an array, which you should look at with PHP's print_r() function.

:!: Note that this will return an array of all of the elements it finds, and you can only go deeper – not shallower.

Availability

  • Available since SimplePie 1.0.

Parameters

namespace (required)

The URL of the XML namespace of the elements you're trying to access. SimplePie has a number of constants for supported namespaces in our Supported XML Namespaces document. If we don't have a constant for it, you can manually add the namespace URL as listed inside the feed.

tag (required)

This is the tag (element) that you want to get.

Examples

Grab the contents of a custom element

$feed = new SimplePie();
$feed->set_feed_url('http://video.google.com/videofeed?type=top100new&num=20&output=rss');
$feed->enable_cache(false);
$success = $feed->init();
$feed->handle_content_type('text/plain');
 
if ($success)
{
	if ($item = $feed->get_item(0))
	{
		// This is probably a bad example because we already support <media:content> natively, but it shows you how to parse through the nodes.
		$media_group = $item->get_item_tags('http://search.yahoo.com/mrss/', 'group');
		$media_content = $media_group[0]['child']['http://search.yahoo.com/mrss/']['content'];
		$file = $media_content[0]['attribs']['']['url'];
		echo $file;
	}
	else
	{
		echo 'Error: Could not get first item';
	}
}
else
{
	echo $feed->error();
}

See Also


reference/simplepie_item/get_item_tags.txt · Last modified: 2011/03/06 03:56 (external edit)