Jump to content

Recommended Posts

Hey, not sure what I'm doing wrong as nothing is displayed in the echo.

 

<?php

  $doc = new DOMDocument();
  $doc->load('http://feeds.feedburner.com/148apps_newest');
  $arrFeeds = array();
  foreach ($doc->getElementsByTagName('description') as $node)
  {
    $itemRSS = array ( 
      'image' => $node->getElementsByTagName('img')->item(0)->nodeValue
      );
    array_push($arrFeeds, $itemRSS);
  }
  
  //print_r($arrFeeds);
  for ($i=0;$i<=40;$i++)
  {
echo $arrFeeds[$i][image];
   	echo ("<br/><br/>");
  }

?>

 

 

print_r($arrFeeds);

outputs blank array items... Hmm

 

Thanks

Link to comment
https://forums.phpfreaks.com/topic/243941-html-parsing/
Share on other sites

I changed the code to

<?php
require_once('simple_html_dom.php');

$html = file_get_html('http://feeds.feedburner.com/148apps_newest');
//echo $html;

// Find all images 
foreach($html->find('img') as $element) 
       echo $element->src . '<br>';

?>

 

to make it simple. It doesn't seem to like reading feeds. It can parse normal html websites like yahoo.com and outputs the image urls as desired. Why won't it parse the url above?

Link to comment
https://forums.phpfreaks.com/topic/243941-html-parsing/#findComment-1252842
Share on other sites

It wont read it even if I change it to <

 

<?php
require_once('simple_html_dom.php');

$html = file_get_html('http://feeds.feedburner.com/148apps_newest');
//echo $html;

// Find all images 
foreach($html->find('<') as $element) 
       echo $element->src . '<br>';

?>

 

Has it got anything to do with the fact it redirects the url to feed:// instead of http:// ?

Link to comment
https://forums.phpfreaks.com/topic/243941-html-parsing/#findComment-1252940
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.