jay1982 Posted July 6, 2011 Share Posted July 6, 2011 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 Quote Link to comment https://forums.phpfreaks.com/topic/241207-passing-the-xml-contents-of-an-url-into-an-array/ Share on other sites More sharing options...
TeNDoLLA Posted July 6, 2011 Share Posted July 6, 2011 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). Quote Link to comment https://forums.phpfreaks.com/topic/241207-passing-the-xml-contents-of-an-url-into-an-array/#findComment-1238965 Share on other sites More sharing options...
jay1982 Posted July 6, 2011 Author Share Posted July 6, 2011 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 Quote Link to comment https://forums.phpfreaks.com/topic/241207-passing-the-xml-contents-of-an-url-into-an-array/#findComment-1238968 Share on other sites More sharing options...
jay1982 Posted July 6, 2011 Author Share Posted July 6, 2011 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. Quote Link to comment https://forums.phpfreaks.com/topic/241207-passing-the-xml-contents-of-an-url-into-an-array/#findComment-1239331 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.