PHP Classes

Xml from URL

Recommend this page to a friend!

      PHP JSON XML Array String Interchanger  >  All threads  >  Xml from URL  >  (Un) Subscribe thread alerts  
Subject:Xml from URL
Summary:Problem outputting Array when retrieving data from URL
Messages:2
Author:William Egan
Date:2014-11-10 15:21:22
 

  1. Xml from URL   Reply   Report abuse  
Picture of William Egan William Egan - 2014-11-10 15:21:22
Hi,
Thanks for the great script.
I need some help if you have time to provide it.

The script works great when the xml output is assigned to a variable directly in the script.
However, when I attempt to retreive the xml output from a URL I get Error messages.
I tried retrieving the XML 2 ways:
$url = "http://66.42.196.109:5609";


$handle = fopen($url, "r");

if($handle){
while(!feof($handle)){
$sampleXml = fgets($handle, 4096);
// echo $sampleXml;
}
fclose($handle);
}

AND
$sampleXml = simplexml_load_file($url);

Any help would be greatly appreciated.


  2. Re: Xml from URL   Reply   Report abuse  
Picture of William Egan William Egan - 2014-11-10 16:51:28 - In reply to message 1 from William Egan
I got this figured out.
I had the following 2 lines in my code:
//header('Content-Type: application/xml');
//header('Access-Control-Allow-Origin: *');
and I was overwritting $xml in the while loop instead of adding to it.

Thanks again for the script. Works perfectly