<?php
header('Content-Type: text/xml');
$doc = domxml_new_doc("1.0");
$root = $doc->add_root("html");
$head = $root->new_child("head", "");
$head->new_child("title", "phpdom test");
echo $doc->dump_mem();
$doc->dump_file("phpdom.xml", false, true);
?>
Also, It works
DomDocument->dump_file
(No version information available, might be only in CVS)
DomDocument->dump_file — Vuelca el árbol XML interno de vuelta a un archivo
Descripción
string DomDocument->dump_file
( string $nombre_archivo
[, bool $modo_compresion
[, bool $formato
]] )
Crea un documento XML desde la representación dom. Esta función es llamada por lo general después de construir un nuevo documento dom desde ceros como en el ejemplo a continuación. El formato especifica si la salida debe tener un formato elegante, o no. El primer parámetro especifica el nombre del archivo y el segundo parámetro, si debe comprimirse o no.
Example #1 Creación de una cabecera de un documento HTML simple
<?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("Este es el título");
$texto = $titulo->append_child($texto);
$doc->dump_file("/tmp/prueba.xml", false, true);
?>
Vea también domdocument_dump_mem(), y domdocument_html_dump_mem().
DomDocument->dump_file
wkshi
22-Jun-2007 08:39
22-Jun-2007 08:39
Nushto
02-Aug-2006 08:06
02-Aug-2006 08:06
The string you pass as a filename should be an absolute path.
For Example:
$doc->dump_file(realpath("test.xml"),false,true);
winghonghibernates at hotmail dot com
14-May-2003 06:37
14-May-2003 06:37
Sometimes it maybe strange in the structure of the XML document when using false, true as the two boolean parameters. Using false, false can solve the problem.
tommy
20-Jul-2002 02:06
20-Jul-2002 02:06
the return value contains the number of bytes, wich are written by this command
