cvs: /php4/ext/domxml domxml.c /php4/tests testdom
| From: | Uwe Steinmann | Date: | Thu, 02 Mar 2000 16:58:37 +0000 |
| Subject: | cvs: /php4/ext/domxml domxml.c /php4/tests testdom | ||
| Groups: | php.version4 | ||
| Request: | Send a blank email to php-version4+get-11365@lists.php.net to get a copy of this message | ||
steinm Thu Mar 2 08:58:37 2000 EDT
Modified files:
/php4/ext/domxml domxml.c
/php4/tests testdom
Log:
- dom class now distinguishes between $dom->root() and $dom->children()
$dom->root() returns just the element, $dom->children() all nodes e.g.
comments
Index: php4/ext/domxml/domxml.c
diff -u php4/ext/domxml/domxml.c:1.22 php4/ext/domxml/domxml.c:1.23
--- php4/ext/domxml/domxml.c:1.22 Thu Mar 2 08:39:49 2000
+++ php4/ext/domxml/domxml.c Thu Mar 2 08:58:06 2000
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: domxml.c,v 1.22 2000/03/02 16:39:49 steinm Exp $ */
+/* $Id: domxml.c,v 1.23 2000/03/02 16:58:06 steinm Exp $ */
#include "php.h"
@@ -55,7 +55,8 @@
static zend_function_entry php_domxmldoc_class_functions[] = {
- PHP_FALIAS(root, domxml_children, NULL)
+ PHP_FALIAS(root, domxml_root, NULL)
+ PHP_FALIAS(children, domxml_children, NULL)
PHP_FALIAS(add_root, domxml_add_root, NULL)
PHP_FALIAS(dtd, domxml_intdtd, NULL)
PHP_FALIAS(dumpmem, domxml_dumpmem, NULL)
@@ -713,9 +714,9 @@
}
/* }}} */
-/* {{{ proto string domxml_root([int doc])
+/* {{{ proto string domxml_rootnew([int doc])
Returns list of children nodes */
-PHP_FUNCTION(domxml_root)
+PHP_FUNCTION(domxml_rootnew)
{
zval *id, **tmp;
int id_to_find;
@@ -778,7 +779,7 @@
/* {{{ proto string domxml_root([int doc_handle])
Returns root node of document */
-PHP_FUNCTION(domxml_rootold)
+PHP_FUNCTION(domxml_root)
{
zval *id, **tmp;
int id_to_find;
@@ -815,16 +816,23 @@
if (!node) {
RETURN_FALSE;
}
- ret = zend_list_insert(node, le_domxmlnodep);
- /* construct an object with some methods */
- object_init_ex(return_value, domxmlnode_class_entry_ptr);
- add_property_resource(return_value, "node", ret);
- add_property_long(return_value, "type", node->type);
- add_property_stringl(return_value, "name", (char *) node->name,
strlen(node->name), 1);
- if(node->content)
- add_property_stringl(return_value, "content", (char *) node->content,
strlen(node->content), 1);
- zend_list_addref(ret);
+ while(node) {
+ if(node->type == XML_ELEMENT_NODE) {
+ ret = zend_list_insert(node, le_domxmlnodep);
+
+ /* construct an object with some methods */
+ object_init_ex(return_value, domxmlnode_class_entry_ptr);
+ add_property_resource(return_value, "node", ret);
+ add_property_long(return_value, "type", node->type);
+ add_property_stringl(return_value, "name", (char *) node->name,
strlen(node->name), 1);
+ if(node->content)
+ add_property_stringl(return_value, "content", (char *) node->content,
strlen(node->content), 1);
+ zend_list_addref(ret);
+ return;
+ }
+ node = node->next;
+ }
}
/* }}} */
Index: php4/tests/testdom
diff -u php4/tests/testdom:1.13 php4/tests/testdom:1.14
--- php4/tests/testdom:1.13 Thu Mar 2 08:39:50 2000
+++ php4/tests/testdom Thu Mar 2 08:58:07 2000
@@ -73,9 +73,11 @@
}
echo "XML Version: ".$dom->version."\n";
$dtd = $dom->dtd();
-$rootnode = $dom->root();
+$rootnode = $dom->children();
foreach($rootnode as $root)
output_node($root);
+$rootnode = $dom->root();
+ output_node($rootnode);
/* This one creates a dom tree made of php objects */
echo "Test 2: creating a tree with php objects\n";