0

I'm trying to retrieve an webpage that has XML data using file_get_contents().

$get_url_report = 'https://...'; // GET URL
$str = file_get_contents($get_url_report);

The problem is that file_get_contents gets only the secure content of the page and returns only some strings without the XML. In Windows IE, if I type in $get_url_report, it would warn it if I want to display everything. If I click yes, then it shows me the XML, which is what I want to store in $str. Any ideas on how to retrieve the XML data into a string from the webpage $get_url_report?

laketuna
  • 3,832
  • 14
  • 59
  • 104
  • Have you tryed to print $str using html_entities? – maaudet Jul 12 '11 at 00:31
  • Thanks for the comments everyone. I don't have access to my files at the moment, but I will look into it tomorrow and put up an update. I did enable openssl in php.ini. In phpinfo(), it shows enabled under PHAR. (I think this is right?) – laketuna Jul 12 '11 at 02:29

2 Answers2

1

You should already be getting the pure XML if the URL is correct. If you're having trouble, perhaps the URL is expecting you to be logged in or something similar. Use a var_dump($str) and then view source on that page to see what you get back.

Either way, there is no magic way to get any linked content from the XML. All you would get is the XML itself and would need further PHP code to process and get any links/images/data from it.

Michael Petrov
  • 2,247
  • 15
  • 15
  • The https has log in ID and password included (so i just put ... in the post). As your suggestion, var_dump() shows all is there and previous comment's html_entities() works well! – laketuna Jul 12 '11 at 16:24
1

Verify if openssl is enable on your php, a good exemple of how to do it: How to get file_get_contents() to work with HTTPS?

Community
  • 1
  • 1
GodFather
  • 3,031
  • 4
  • 25
  • 36