Ver Mensaje Individual
  #1 (permalink)  
Antiguo 29/10/2009, 09:48
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
setIdAttribute() me falla en DOM PHP

Estoy con PHP, usando un metodo llamado "setIdAttribute()" para poder seleccionar mis items xml mediante un identificador unicos.

Me da este error:

Código PHP:
<b>Fatal error</b>: [COLOR="Red"Call to undefined method DOMDocument::setIdAttribute() i[/COLOR]<b>C:wampwwwagenda jovenNovedadesphpeliminar.php</bon line <b>21</b><br /> 
Asi es mi xml:

Código PHP:
 <item dir="fotos" id="almuerzo_fao_telefood_.jpg">
    <
foto><![CDATA[almuerzo_fao_telefood_.jpg]]></foto>
    <
titulo><![CDATA[ ]]></titulo>
    <
descripcion><![CDATA[ ]]></descripcion>
  </
item
Y esta es mi llamada:

Código PHP:
$xml = new DOMDocument();
$xml->load($archivo_xml);
// con esto logro que funcione el select by ID.
[COLOR="#ff0000"]$xml->setIdAttribute('id'true);[/COLOR]

$a_borrar $xml->getElementById($foto)->item(0);

$a_borrar->getElementsByTagName("titulo")->item(0)->childNodes->item(0)->nodeValue "";
$a_borrar->getElementsByTagName("descripcion")->item(0)->childNodes->item(0)->nodeValue "";
$xml->formatOutput true;
$xml->save($archivo_xml); 
Que es lo que pasa que no funciona el metodo?