From: Uwe Steinmann Date: Wed, 9 Feb 2000 14:07:44 +0000 (+0000) Subject: - new function to read and parse xml doc from file X-Git-Tag: BEFORE_SAPIFICATION_FEB_10_2000~34 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=9603c7cc8371aed151d43cb8edbe792a8112089e;p=php - new function to read and parse xml doc from file --- diff --git a/ext/domxml/domxml.c b/ext/domxml/domxml.c index 9358a08b99..e07f0f08f5 100644 --- a/ext/domxml/domxml.c +++ b/ext/domxml/domxml.c @@ -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) diff --git a/ext/domxml/php_domxml.h b/ext/domxml/php_domxml.h index 36ff9807b5..1c3f6e759f 100644 --- a/ext/domxml/php_domxml.h +++ b/ext/domxml/php_domxml.h @@ -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 */ diff --git a/tests/testdom b/tests/testdom index d8d3d12d3e..58a41a9952 100644 --- a/tests/testdom +++ b/tests/testdom @@ -70,4 +70,5 @@ $table->setattr("WIDTH", "100%"); $table->newchild("TR", " "); echo $doc->dumpmem(); +echo {$root->children()}[0]; ?>