1

I have been given an XML feed to get data from to use on a clients website, I have worked with XML before when the file is somfile.xml and for this I use simplexml_load_file, however the feed I have been given to work with is mmluxuryvillas.com/mmtoxml.php a PHP file. simplexml_load_file returns bool(false) when trying to read this file.

Below is the code I am using, which works if I create a test.xml file but not on the feed I have been given, how can I iterate through this data:

$url = "mmluxuryvillas.com/mmtoxml.php";
$xml = simplexml_load_file($url);

var_dump($xml);

foreach($xml->item as $item) {

    echo "<p>".$item->inmueble."</p>";

}

Regards Rick

Wilson
  • 176
  • 1
  • 11
Rik89
  • 157
  • 4
  • 22
  • 1
    You might have to use `file_get_contents` to get the contents from PHP file before applying `simplexml_load_file` – prava Jun 19 '14 at 09:10
  • ahhhh I will answer my own question when I can the url should be starting with http:// – Rik89 Jun 19 '14 at 09:16
  • When you develop, spare yourself some time by enabling error reporting and logging to the highest level. you will then get a lot of useful information what might have been gone wrong. http://stackoverflow.com/questions/845021/how-to-get-useful-error-messages-in-php – hakre Jun 19 '14 at 17:15

1 Answers1

0

The answer is that the http:// was missing from the url, with this it works perfectly... Hope this helps someone in the future!

Rik89
  • 157
  • 4
  • 22