Ver Mensaje Individual
  #2 (permalink)  
Antiguo 29/10/2009, 10:12
Avatar de mayid
mayid
Colaborador
 
Fecha de Ingreso: marzo-2009
Ubicación: BsAs
Mensajes: 4.014
Antigüedad: 15 años, 1 mes
Puntos: 101
Respuesta: setIdAttribute() me falla en DOM PHP

Probe con Xpath, y esto si funciona:

Cita:
$xml = new DOMDocument();
$xml->load($archivo_xml);
// con esto logro que funcione el select by ID.
//$xml->setIdAttribute('id', true);
//$a_borrar = $xml->getElementById($foto)->item(0);
//echo $set->item(0)->getAttributeNode("id")->nodeValue;


$xpath = new DOMXPath($xml);
$set = $xpath->query("//item[@id = '".$a_eliminar."']");

$set->item(0)->getElementsByTagName("titulo")->item(0)->childNodes->item(0)->nodeValue = "";
$set->item(0)->getElementsByTagName("descripcion")->item(0)->childNodes->item(0)->nodeValue = "";
$xml->formatOutput = true;
$xml->save($archivo_xml);
Pero hubiera sido bueno hacer la consulta sin Xpath.

Última edición por mayid; 29/10/2009 a las 10:28