Tema: Error Xml
Ver Mensaje Individual
  #4 (permalink)  
Antiguo 06/05/2011, 09:47
Viclian
 
Fecha de Ingreso: marzo-2008
Mensajes: 4
Antigüedad: 16 años, 2 meses
Puntos: 0
Respuesta: Error Xml

Ok, gracias por comentar. El uso de htmlentities, si está considerado y la manipulación del xml con DomDocument, es como sigue:

//Si no existe se crea
{
$xml = new DOMDocument('1.0', 'UTF-8');
$xml->formatOutput = true;
$raiz = $xml->createElement('padre');
$xml->appendChild($raiz);
$xml->save('file.xml');
}

$xml = $this->load('file.xml'); //Si existe se lee
$nodo = $this->createElement('hijo');


$nieto = $this->createElement('dato');
$this->appendChild($nieto);
$datoText = $this->createTextNode(htmlentities($data));
$nieto->appendChild($datoText);
$nodo->appendChild($nieto);


$this->documentElement->appendChild($nodo);

$this->save('file.xml');

Se inserta correctamente los nodos, pero en algún momento cuando el archivo llega a un tamaño considerable y se pueden apreciar más de una petición por segundo, la inserción del nodo se queda a la mitad, el tab se queda mal cerrado y la estructura se daña.