]> granicus.if.org Git - php/commitdiff
add the ability to serialize the contents back to a file
authorSterling Hughes <sterling@php.net>
Mon, 19 May 2003 13:33:01 +0000 (13:33 +0000)
committerSterling Hughes <sterling@php.net>
Mon, 19 May 2003 13:33:01 +0000 (13:33 +0000)
ext/simplexml/simplexml.c

index e00c045622cfb0c32038fd39b679faade821863f..4c207253d91152a6933423e4757bc192e0d7eafb 100644 (file)
@@ -392,9 +392,30 @@ PHP_FUNCTION(simplexml_load_file)
 }
 /* }}} */
 
+/* {{{ proto bool simplexml_save_file(string filename, simplexml_element node)
+   Save a document from a SimpleXML node */
+PHP_FUNCTION(simplexml_save_document_file)
+{
+       php_sxe_object *sxe;
+       zval           *element;
+       char           *filename;
+       int             filename_len;
+       
+       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "sz", &filename, &filename_len, &element) == FAILURE) {
+               return;
+       }
+
+       sxe = php_sxe_fetch_object(element TSRMLS_CC);
+
+       xmlSaveFile(filename, sxe->document);
+
+       RETURN_TRUE;
+}
+/* }}} */
 
 function_entry simplexml_functions[] = {
        PHP_FE(simplexml_load_file, NULL)
+       PHP_FE(simplexml_save_document_file, NULL)
        {NULL, NULL, NULL}
 };