Question

I'm attempting to parse an rss feed to display images only. I am using a generic wordpress feed and would like to strip out everything that isn't an image.

I've been playing around with simplepie and but haven't been able to find a solid way to display images only.

I found this old simplepie forum post (http://simplepie.org/support/viewtopic.php?id=643) but was unable to get the code working. I suppose it may just be outdated by now but am unsure.

I'm not tied to simplepie but do need to work within php and output html. Any help would be greatly appreciated!

Was it helpful?

Solution

Or something like:

$xml = simplexml_load_file($xml_file_path);
$imgs = $xml->xpath('/rss/channel/image');
foreach($imgs as $image) {
    echo $image->url;
}

OTHER TIPS

Check out SimpleXML.

Using it and xpath should get you what you need.

$feed = simplexml_load_file('foo.xml');

foreach ($feed->xpath('//img') as $imgnode) {
   // ...
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top