To read XML files use:
$XMLFile = new XMLReader();
if($XMLFile->open('file.xml') === TRUE){
while($XMLFile->read()) {
//Do something
}
$XMLFile->close();
}
If I will find in xml file sample string:
!+_)(*&^%$#@!~}|"?,../;'\[]=-
Critical error is displayed and the parsing is terminated:
Warning: XMLReader::read() [xmlreader.read]: file.xml:16: parser error : xmlParseEntityRef: no name in test.php on line 841
Warning: XMLReader::read() [xmlreader.read]: An Error Occured while reading in test.php on line 841
In this case, I would like to handle the error and delete the xml file. Someone may know how to fix this error?