简体   繁体   中英

How to open an xml file, in php using XMLReader, and using an https address?

I am trying to open an XML file that is in a https address. I can see the XML file from my browser, and there are no log ins. I am trying to use the XMLReader object in PHP, and I can't seem to get the file through the open method. It returns false. I can't seem to find any errors in the apache log other than complaints about using the next function when the open function didn't work.

This is my corresponding code with an example url:

$xml_url = 'https://www.example.com/test.xml'
$read = new XMLReader;
if (!$read->open($xml_url)) {
  echo "bad open";
}

If you want to use an HTTPS url you have to make sure that the openssl extension is activated in PHP

php.ini

extension=php_openssl.dll

or if you are unix

extension=php_openssl.so

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM