downloads | documentation | faq | getting help | mailing lists | licenses | wiki | reporting bugs | php.net sites | conferences | my php.net

search for in the

DOMDocument::saveHTML> <DOMDocument::relaxNGValidateSource
[edit] Last updated: Fri, 17 May 2013

view this page in

DOMDocument::save

(PHP 5)

DOMDocument::save Copia el árbol XML interno a un archivo

Descripción

int DOMDocument::save ( string $filename [, int $options ] )

Crea un documento XML desde la representación DOM. Esta función normalmente se llama después de construir un nuevo documento desde ceros, como en el ejemplo de abajo.

Parámetros

filename

La ruta al documento XML guardado.

options

Opciones Adicionales. Actualmente sólo está soportada LIBXML_NOEMPTYTAG.

Valores devueltos

Devuelve el número de bytes escritos o FALSE si ocurrió un error.

Historial de cambios

Versión Descripción
5.1.0 Se añadió el parámetro options

Ejemplos

Ejemplo #1 Guardar un árbol DOM en un fichero

<?php

$doc 
= new DOMDocument('1.0');
// queremos una impresión buena
$doc->formatOutput true;

$root $doc->createElement('book');
$root $doc->appendChild($root);

$title $doc->createElement('title');
$title $root->appendChild($title);

$text $doc->createTextNode('Este es el título');
$text $title->appendChild($text);

echo 
'Escrito: ' $doc->save("/tmp/test.xml") . ' bytes'// Escrito: 72 bytes

?>

Ver también



DOMDocument::saveHTML> <DOMDocument::relaxNGValidateSource
[edit] Last updated: Fri, 17 May 2013
 
add a note add a note User Contributed Notes DOMDocument::save - [4 notes]