Skip to main content

I need to grab the data from the “enclosure” tag from the following feed:

In the example, you can modify the “enclosure” field to any of the fields you need help grabbing. ¬†This is using the simplexml_load_string command.

$url = '';
$xml = file_get_contents($url);
$obj = simplexml_load_string($xml);

foreach ($obj->channel->item as $item)
    echo PHP_EOL . (string)$item->enclosure['url'];

This will give you an output on your page of:

You can see the demo output here.

Leave a Reply