From 66c68da22b17120033e8fd76e58ba590c6d2f758 Mon Sep 17 00:00:00 2001 From: Rob Richards Date: Mon, 29 Dec 2003 16:44:47 +0000 Subject: [PATCH] Fixed bug #26743 (getElementsByTagName doesn't work properly) --- ext/dom/dom_iterators.c | 4 ++++ ext/dom/nodelist.c | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/ext/dom/dom_iterators.c b/ext/dom/dom_iterators.c index fe531359968..4ddb0a56e44 100644 --- a/ext/dom/dom_iterators.c +++ b/ext/dom/dom_iterators.c @@ -207,6 +207,8 @@ static void php_dom_iterator_move_forward(zend_object_iterator *iter TSRMLS_DC) basenode = dom_object_get_node(objmap->baseobj); if (basenode && (basenode->type == XML_DOCUMENT_NODE || basenode->type == XML_HTML_DOCUMENT_NODE)) { basenode = xmlDocGetRootElement((xmlDoc *) basenode); + } else { + basenode = basenode->children; } curnode = dom_get_elements_by_tag_name_ns_raw(basenode, objmap->ns, objmap->local, &previndex, iter->index); } @@ -264,6 +266,8 @@ zend_object_iterator *php_dom_get_iterator(zend_class_entry *ce, zval *object TS } else { if (nodep->type == XML_DOCUMENT_NODE || nodep->type == XML_HTML_DOCUMENT_NODE) { nodep = xmlDocGetRootElement((xmlDoc *) nodep); + } else { + nodep = nodep->children; } curnode = dom_get_elements_by_tag_name_ns_raw(nodep, objmap->ns, objmap->local, &curindex, 0); } diff --git a/ext/dom/nodelist.c b/ext/dom/nodelist.c index 72b7577df1e..1f32527e98f 100644 --- a/ext/dom/nodelist.c +++ b/ext/dom/nodelist.c @@ -71,6 +71,8 @@ int dom_nodelist_length_read(dom_object *obj, zval **retval TSRMLS_DC) } else { if (nodep->type == XML_DOCUMENT_NODE || nodep->type == XML_HTML_DOCUMENT_NODE) { nodep = xmlDocGetRootElement((xmlDoc *) nodep); + } else { + nodep = nodep->children; } curnode = dom_get_elements_by_tag_name_ns_raw(nodep, objmap->ns, objmap->local, &count, -1); } @@ -129,6 +131,8 @@ PHP_FUNCTION(dom_nodelist_item) } else { if (nodep->type == XML_DOCUMENT_NODE || nodep->type == XML_HTML_DOCUMENT_NODE) { nodep = xmlDocGetRootElement((xmlDoc *) nodep); + } else { + nodep = nodep->children; } itemnode = dom_get_elements_by_tag_name_ns_raw(nodep, objmap->ns, objmap->local, &count, index); }