]> granicus.if.org Git - php/commitdiff
- new function to read and parse xml doc from file
authorUwe Steinmann <steinm@php.net>
Wed, 9 Feb 2000 14:07:44 +0000 (14:07 +0000)
committerUwe Steinmann <steinm@php.net>
Wed, 9 Feb 2000 14:07:44 +0000 (14:07 +0000)
ext/domxml/domxml.c
ext/domxml/php_domxml.h
tests/testdom

index 9358a08b99a8d729cb43f2f1724142c59fd1395f..e07f0f08f5a0b36c7fb7e614341c7dc6fa01c9a5 100644 (file)
@@ -35,7 +35,9 @@ static zend_class_entry *domxmlattr_class_entry_ptr;
 
 static zend_function_entry php_domxml_functions[] = {
        PHP_FE(getdom,  NULL)
+       PHP_FE(getdomfile,      NULL)
        PHP_FALIAS(dom,         getdom, NULL)
+       PHP_FALIAS(domfile,             getdomfile,     NULL)
        PHP_FE(domxml_root,     NULL)
        PHP_FE(domxml_addroot,  NULL)
        PHP_FE(domxml_dumpmem,  NULL)
@@ -697,6 +699,33 @@ PHP_FUNCTION(getdom)
 }
 /* }}} */
 
+/* {{{ proto class dom(string filename)
+   Creates dom object of xml document in file*/
+PHP_FUNCTION(getdomfile)
+{
+       pval *arg;
+       xmlDoc *docp;
+       int ret;
+       
+       if (ARG_COUNT(ht) != 1 || getParameters(ht, 1, &arg) == FAILURE) {
+               WRONG_PARAM_COUNT;
+       }
+       convert_to_string(arg);
+
+       docp = xmlParseFile(arg->value.str.val);
+       if (!docp) {
+               RETURN_FALSE;
+       }
+       ret = zend_list_insert(docp, le_domxmldocp);
+
+       /* construct an object with some methods */
+       object_init_ex(return_value, domxmldoc_class_entry_ptr);
+       add_property_long(return_value, "doc", ret);
+       add_property_stringl(return_value, "version", (char *) docp->version, strlen(docp->version), 1);
+       zend_list_addref(ret);
+}
+/* }}} */
+
 /* {{{ proto string domxml_newchild([int node_handle], string name, string content)
    Adds child node to parent node */
 PHP_FUNCTION(domxml_newchild)
index 36ff9807b5404ea0994d69782edbbe54d74f9434..1c3f6e759f75e516561dc95ea381240a4ae3c4c3 100644 (file)
@@ -44,6 +44,7 @@ extern zend_module_entry php_domxml_module_entry;
 extern PHP_MINIT_FUNCTION(domxml);
 extern PHP_MINFO_FUNCTION(domxml);
 PHP_FUNCTION(getdom);
+PHP_FUNCTION(getdomfile);
 PHP_FUNCTION(domxml_newxmldoc);
 
 /* Class Document methods */
index d8d3d12d3ea42698d3817270c67c417c6e729db9..58a41a995246739662c6c4a3352a3ea67c9808a2 100644 (file)
@@ -70,4 +70,5 @@ $table->setattr("WIDTH", "100%");
 $table->newchild("TR", " ");
 echo $doc->dumpmem();
 
+echo {$root->children()}[0];
 ?>