I am trying to work on an XML Based problem. So far, it's proving to be a bummer for some reason. My code is only two lines and for some reason nothing is loading in.
The code:
$xmlString = file_get_contents('file.xml');
$xmlObject = simplexml_load_string($xmlString);
// also in the above line I have tried
// 1. new SimpleXMLElement('file.xml')
// 2. simplexml_load_file('file.xml')
The functions do not load, and this I can tell by var_dumping $xmlObject, which returns boolean false.
file_get_contents does load the string $xmlString and var_dumping it returns the string, so location of the file path is not an issue here.
Anybody know what's happening here?
Thanks
Your XML is probably invalid. Look at the fine PHP manual that describes how to handle those errors:
http://php.net/manual/en/simplexml.examples-errors.php
You can also validate your XML with command line tools like xmllint: