Ver Mensaje Individual
  #1 (permalink)  
Antiguo 21/12/2008, 11:56
Avatar de anlhp
anlhp
 
Fecha de Ingreso: agosto-2008
Mensajes: 121
Antigüedad: 15 años, 8 meses
Puntos: 1
Exclamación Infierno DOM xml

hello there folks ;)
a ver, alguien tiene idea de como utilizar la api DOM xml de php?? es qe la documentacion en php.net es un poco pobre y los ejemplos qe ponen ninguno me funciona, segun mi phpinfo() tengo esta api activada y deberia funcionar, pero lo siguiente no funciona:

Código PHP:
$doc domxml_new_doc("1.0");
$raiz $doc->create_element("HTML");
$raiz $doc->append_child($raiz);
$cabecera $doc->create_element("HEAD");
$cabecera $raiz->append_child($cabecera);
$titulo $doc->create_element("TITLE");
$titulo $cabecera->append_child($titulo);
$texto $doc->create_text_node("created with DOM xml API");
$texto $titulo->append_child($texto);
echo 
"<PRE>";
echo 
htmlentities($doc->dump_mem(true));
echo 
"</PRE>"
y arroja los siguientes errores:

Warning: domnode::append_child() expects parameter 1 to be object, null given in C:\Documents and Settings\anler\Mis documentos\Sitios\galeria\public\Labs\prueba.php

Fatal error: Call to a member function append_child() on a non-object in C:\Documents and Settings\anler\Mis documentos\Sitios\galeria\public\Labs\prueba.php


en cambio este qe hice creando explicitamente las clases si qe me funciona

Código PHP:
$doc domxml_new_doc("1.0");
$raiz = new DOMElement('html');
$cabecera = new DOMElement('head');
$titulo = new DOMElement('title');
$titulo->append_child(new DOMText('created with DOM xml API'));
$cabecera->append_child($titulo);
$raiz->append_child($cabecera);
$doc->append_child($raiz);
echo 
"<PRE>";
echo 
htmlentities($doc->dump_mem(true));
echo 
"</PRE>"
y al final no se tios, estoy haciendo las cosas por intuicion pero me molesta ver que lo que encuentro en la ayuda de php no me sirve y no saber por que me estresa