I’m getting a lot of errors when I browse a clients site securely that have to do with the simplexml_load_file function. Here’s an example:
Warning: simplexml_load_file() [function.simplexml-load-file]: https://xxxxxxxx/settings.xml:1: parser error : Document is empty in /xx/xx/xx/xx/xx/ on line 0
The site is on a dedicated server from SingleHop. It only happens when I browse the site with https://, and works fine when browsed with http://.
Seems to be loading the XML file just fine with https:// as well:
https://consumerstrust.org/wp-content/plugins/easyfanpagedesign/framework/settings.xml
The XML is parsed from a class:
public function efpd_load_settings($xmlfile){
$xmlparse=simplexml_load_file($xmlfile);
$settings=array();
$setint=0;
foreach($xmlparse->option as $xml){
$option[$setint]=(array)$xml;
array_push($settings,$option[$setint]);
$setint++;
}
return $settings;
}
and ran like this:
$efpdxml=plugins_url('settings.xml',__FILE__); // plugins_url() is a WP function - returns the value just fine.
$efpdsettings=Efpd::efpd_load_settings($efpdxml);
Is this something that happens commonly? Also anything to fix it? If you need any more info to help me solve this just let me know and I will provide it.
Thanks.
I figured out my own problem, but thank you to those of you who tried helping me. I appreciate it.
My solution:
This was being run in WordPress, so I really should have posted this in the WPSE site, but I don’t blame anyone for not knowing all about WP from this site if they didn’t.
The function
plugins_url()should not have been used to define the path to the XML file, I should have been usingdirname(__FILE__).'/settings.xml'– which is pretty obvious as to why if you know howplugins_url()works, I overlooked it completely but in the end solved my problem.