I have to parse automatic generate XML files to PHP, without success.
I'm fetching a folder with XML files and each file has to be parsed. The weird thing is, that I only get the version as output.
My code:
$xml_folder = "/var/www/sitename/xml_folder/";
$xml_files = scandir($xml_folder);
$xml_files = array_diff($xml_files, array('.', '..'));
foreach($xml_files as $file) {
$xml_file = $xml_folder . $file;
$xml = simplexml_load_file($xmlfile);
print_r($xml);
}
Now, my output looks like this:
The XML looks like a normal generated XML, here is a screenshot preview of it:
Sure, it's not structured, but any browser can handle it and creates a valid structure.
Is the structure important for simplexml
?
I tried a bunch of variations to make it work (even with simplexml_load_string
), but nothing won't work.