Jump to content

HTML Parsing


javawizkid

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.