Jump to content

Passing the XML contents of an URL into an array.. ?


jay1982

Recommended Posts

Hi,

 

I need to send the XML contents of an URL into an array, so i can use certain variables returned by the URL in other function calls… for example

 

The URL i'm dealing with is formatted like so: https://[static_url_goes_here.com]/request=[variable_guid_goes_here]

 

If displaying this URL in a browser window, it looks like a normal .XML document.

 

However, since the variable following the "/request" is different every time, and does not end in .XML, how can i pass the results of this URL into a variable so I can extract data from the returned XML?

 

I did originally try something very basic with simplexml_load_(string/file) ... but didn't get very far.

 

Any information would be very much appreciated :)

Maybe use file_get_contents to get the url data in a string variable and then parse it with some XML parsing tool, say for example PHP's DOMDocument (or simplexml).

 

Thanks for the quick reply :)  I'll give this a shot tomorrow at work.

 

Cheers

Maybe use file_get_contents to get the url data in a string variable and then parse it with some XML parsing tool, say for example PHP's DOMDocument (or simplexml).

 

Thanks for the quick reply :)  I'll give this a shot tomorrow at work.

 

Cheers

 

Hi,

 

FYI, this worked perfectly.

 

I tried the first time and received an error "Message : file_get_contents() [function.file-get-contents]: Unable to find the wrapper "https" - did you forget to enable it when you configured PHP? "

 

... did a bit of Googling, turned out I needed to install the OpenSSL extension for PHP.

 

I did this, then re-tried my code and it's working..

 

Thanks again.

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.