hno Posted October 16, 2012 Share Posted October 16, 2012 HI every one i've rss reader that using DOMDocument .I just have a problem , I want to get image url from a feed but I couldn't use it . This is my code a xml example of this feed : $doc = new DOMDocument(); $doc->load('http://feeds.gawker.com/lifehacker/full'); $arrFeeds = array(); foreach ($doc->getElementsByTagName('item') as $node) { print('<div style="width:100%" class="option"><strong>'); $a = $node->getElementsByTagName('title')->item(0)->nodeValue; print("$a"); echo "<br /><br />"; $a = $node->getElementsByTagName('image')->item(0)->nodeValue; print("$a"); } This is a part of this feed : <link>[url="http://lifehacker.com</link>"]http://lifehacker.com</link>[/url] <description>Computers make us more productive. Yeah, right. Lifehacker recommends the software downloads and web sites that actually save time. Don't live to geek; geek to live.</description> <language>en</language> <pubDate>Tue, 16 Oct 2012 11:10:31 GMT</pubDate> <lastBuildDate>Tue, 16 Oct 2012 11:10:31 GMT</lastBuildDate> <ttl>2</ttl> <image> <title>Lifehacker</title> <url>[url="http://ganja.gawkerassets.com/assets/base/img/thumbs140x140/lifehacker.com.png</url>"]http://ganja.gawkera...r.com.png</url>[/url] <link>[url="http://lifehacker.com</link></image>"]http://lifehacker.co...</link></image>[/url] How can I get the image url from it ? Thanks Link to comment https://forums.phpfreaks.com/topic/269526-problem-with-getting-image-url-from-rss-using-domdocument/ Share on other sites More sharing options...
Barand Posted October 16, 2012 Share Posted October 16, 2012 You can get it this way <?php $xml = simplexml_load_file('http://feeds.gawker.com/lifehacker/full'); echo $xml->channel->image->url; ?> Link to comment https://forums.phpfreaks.com/topic/269526-problem-with-getting-image-url-from-rss-using-domdocument/#findComment-1385511 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.