I have a large xml file (60Mb) that I want to parse and insert each record in MySQL DB. I'm using simpleXML to do so and worked like a charm in Xamp but does not on live hosted website. I get no errors so I dont know why the $xml object keeps returning false. Is it becacause of the large amount of records in the XML?
require('connectDB.php');
$query = "INSERT INTO myTable (cp,colonia,municipio,ciudad,estado) VALUES (?,?,?,?,?)";
if($stm = $con->prepare($query)){
if(file_exists('CPdescarga.xml')){
$xml = simplexml_load_file("CPdescarga.xml", 'SimpleXMLElement', LIBXML_COMPACT | LIBXML_PARSEHUGE);
if($xml === false){
echo "No se cargó el archivo correctamente";
foreach (libxml_get_errors() as $error){
echo "\t". $error->message;
}
} else{
$error = 0;
foreach($xml->table AS $registro){
$stm->bind_param('sssss',$registro->d_codigo,$registro->d_asenta,$registro->D_mnpio,$registro->d_ciudad,$registro->d_estado);
if(!$stm->execute()){
$error++;
}
}
echo "Se presentaron $error errores!";
}
} else{
echo "No existe el archivo!";
}
} else{
echo "No se pudo preparar la consulta";
}
$stm->close();
$con->close();`