Warning: simplexml_load_file() [function.simplexml-load-file]: I/O warning : failed to load external entity "USD_en_productdata/USD_en_productdata.xml"
the code
$src=simplexml_load_file("USD_en_productdata/USD_en_productdata.xml");
foreach($src->ProductItem as $i){
}
Try to pass full directory path if you are trying to load xmls held at your server
simplexml_load_file($_SERVER['DOCUMENT_ROOT'].'/uproYourFoldet/USD_en_productdat/USD_en_productdata.xml')
or if you want to access xml by http protocol you will need to set allow_url_fopen ON in php.ini or
ini_set('allow_url_fopen ','ON');
in your code. or you can also do this if you are using php version <5
$temp = file_get_contents($url);
$XmlObj = simplexml_load_string($temp);
Looks like your path might not be correct.
In my experience, it's best to surround simplexml_load_file and subsequent functions with if statements with file_exists(...) as the condition.
So in your case:
if(file_exists($_SERVER['DOCUMENT_ROOT'].'/yourPathToFile/...')) {
simplexml_load_file($_SERVER['DOCUMENT_ROOT'].'/urltoYourFolder/USD_en_productdat/USD_en_productdata.xml')
}
EDIT: spelling
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With