Ho scritto una funzione che legge da un file XML e scrive i dati letti in un database.
La funzione esegue quello che deve fare solo che mi appare il segunete errore: "Fatal error: Uncaught exception 'Exception' with message 'Serialization of 'SimpleXMLElement' is not allowed' in ...".
Qualcuno sa darmi spiegazioni in merito ? Come posso evitarlo ?

La funzione in questione è la seguente:

public function syncAction() {
if (file_exists($this->strXmlPath . 'generalDigit.xml')) {
$xml = simplexml_load_file($this->strXmlPath . 'generalDigit.xml');
$em = $this->get('doctrine.orm.entity_manager');
$arrType = array();
foreach ($xml->types->type as $type) $arrType[settype($type["id"], "int")] = $type->desc[0];
foreach ($xml->article as $articolo) {
$clsArticolo = new articles();
$clsArticolo->articleCode = $articolo['Code'];
$clsArticolo->DescIta = $articolo->Desc->Value[1];
$clsArticolo->Type = $articolo->Type;
$clsArticolo->TypeDescIta = $arrType[settype($articolo->Type, "int")];
$em->persist($clsArticolo);
$em->flush();
}
$strMsg = "Sincronizzazione terminata con successo";
} else $strMsg = "File di sincronizzazione assente";
return $this->render('GMCCatalogsefault:msg.html.twig', array('strMsg' => $strMsg));
}

Ho utilizzato il framework symfony.