cvs: /php4/ext/domxml domxml.c php_domxml.h /php4/tests testdom
| From: | Uwe Steinmann | Date: | Wed, 09 Feb 2000 14:08:14 +0000 |
| Subject: | cvs: /php4/ext/domxml domxml.c php_domxml.h /php4/tests testdom | ||
| Groups: | php.version4 | ||
| Request: | Send a blank email to php-version4+get-9980@lists.php.net to get a copy of this message | ||
steinm Wed Feb 9 06:08:14 2000 EDT
Modified files:
/php4/ext/domxml domxml.c php_domxml.h
/php4/tests testdom
Log:
- new function to read and parse xml doc from file
Index: php4/ext/domxml/domxml.c
diff -u php4/ext/domxml/domxml.c:1.11 php4/ext/domxml/domxml.c:1.12
--- php4/ext/domxml/domxml.c:1.11 Wed Feb 9 04:46:31 2000
+++ php4/ext/domxml/domxml.c Wed Feb 9 06:07:44 2000
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: domxml.c,v 1.11 2000/02/09 12:46:31 steinm Exp $ */
+/* $Id: domxml.c,v 1.12 2000/02/09 14:07:44 steinm Exp $ */
#include "php.h"
@@ -35,7 +35,9 @@
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)
@@ -684,6 +686,33 @@
convert_to_string(arg);
docp = xmlParseMemory(arg->value.str.val, arg->value.str.len);
+ 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 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;
}
Index: php4/ext/domxml/php_domxml.h
diff -u php4/ext/domxml/php_domxml.h:1.5 php4/ext/domxml/php_domxml.h:1.6
--- php4/ext/domxml/php_domxml.h:1.5 Thu Feb 3 09:21:23 2000
+++ php4/ext/domxml/php_domxml.h Wed Feb 9 06:07:44 2000
@@ -29,7 +29,7 @@
*/
-/* $Id: php_domxml.h,v 1.5 2000/02/03 17:21:23 steinm Exp $ */
+/* $Id: php_domxml.h,v 1.6 2000/02/09 14:07:44 steinm Exp $ */
#ifndef _PHP_DOMXML_H
#define _PHP_DOMXML_H
@@ -44,6 +44,7 @@
extern PHP_MINIT_FUNCTION(domxml);
extern PHP_MINFO_FUNCTION(domxml);
PHP_FUNCTION(getdom);
+PHP_FUNCTION(getdomfile);
PHP_FUNCTION(domxml_newxmldoc);
/* Class Document methods */
Index: php4/tests/testdom
diff -u php4/tests/testdom:1.4 php4/tests/testdom:1.5
--- php4/tests/testdom:1.4 Wed Feb 9 04:46:32 2000
+++ php4/tests/testdom Wed Feb 9 06:07:44 2000
@@ -70,4 +70,5 @@
$table->newchild("TR", " ");
echo $doc->dumpmem();
+echo {$root->children()}[0];
?>