SimpleXML with external files?

liunx

Guest
I need some help!

I have an application I'm writing that needs to retrieve an XML response from a server. I tried to use simplexml_load_file, but it doesn't seem to like loading the external file. Here is a code sample for a page that my form posts to:
$user = $_POST['UserId'];
$pass= $_POST['Password'];
$sess = $_POST['SessId'];
$rv = $_POST['RS'];
$rs = $_POST['RV'];

$xmlUrl = "https://somesite.com/app?UserId=$user&Password=$pass&SessId=$sess&RS=$rs&RV=$rv";

$results = simplexml_file_load($xmlUrl);
echo $results;

Here is the error I get:
Warning: warning: filed to load external entity "https://somesite.com/app?UserId=me&Password=blah&SessId=New:mysite&RS=100&RV=50" in C:\\path\to\myfile.php on line 11

Can you load external files with simplexml? Is there a better way to retrieve an xml response? Is it possibly because of the https?

I'd appreciate any help? Thanks!

EddyFrom the looks of it, simplexml_load_file() doesnt allow for files off the local filesystem.

You might still be able to use conventional methods (fopen(), fsockopen() etc) to obtain the string and then use simplexml_load_string() instead.Laser,

Thanks for the followup. I tried using the socket code from php.net as an example; plugging in my url and socket, but that didnt' work. Seems I can't do an HTTPS connection that way; php gives me an error that I might not have that transport enabled. After reading on php.net on the socket functions it appears i only have tcp and udp enabled and I couldn't find any documentation on how to add transports.

BTW FireFox rocks :)use simplexml_load_file() - your code example has the last two words transponsed (simplexml_file_load).

- MRB
 
Back
Top