I currently have a script (phpSysInfo) that checks my server information. They have provided a file called xml.php - when I load this file in the URL, the content of an .xml file is generated.
My question is, how can I get data from this file/URL with PHP?
I have tried using simpleXML, but it doesn't seems to can open a .php file. Therefore I am stuck.
You'd need to execute the PHP file. Doing file_get_contents('xml.php')
will simply read the raw PHP code.
Something like:
ob_start();
include('xml.php');
$data = ob_get_clean();
$xml = new SimpleXML($data);
would do the trick. The include()
will execute the PHP script. And the ob_* functions will capture its output for you, returning it into the $data variable.