-1

I'm trying to parse an XML feed by using PHP and I keep getting errors,

 <?php
     $html = simplexml_load_file('http://api.hotukdeals.com/rest_api/v2/?key=6948de072326c21e9f7c76b2a153e49a&merchant=tesco-com-and-in-store&online_offline=offline&order=new&forum=deals&results_per_page=10');

 foreach ($html as $dealinfo):
         $api_item=$dealinfo->title;
 endforeach;

 ?>

Can anyone help where I may be going wrong with this?

Heres the link to the page.

http://simpleclassifieds.co.uk/deal.php

Dave Kane
  • 69
  • 2
  • 8

1 Answers1

1

your foreach loop should be like this

foreach ($html->deals->api_item as $dealinfo):
        echo $dealinfo->title."<br />";
 endforeach;
Kamran
  • 2,711
  • 2
  • 17
  • 24
  • super, that makes much more sense now. Thanks!! – Dave Kane Apr 02 '15 at 10:10
  • This answer is only useful for the person asking the question and carries no or only little information for future visitors. It might have been an improvement to not answer the question at all but to direct to a reference question instead. – hakre Apr 03 '15 at 05:29