|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #26531 get_elements_by_tag_name() wildcard fails
Submitted: 2003-12-05 06:38 UTC Modified: 2003-12-05 14:20 UTC
From: jon at hiveminds dot net Assigned:
Status: Closed Package: DOM XML related
PHP Version: 4.3.4 OS: Windows 2000 / SP4
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: jon at hiveminds dot net
New email:
PHP Version: OS:


 [2003-12-05 06:38 UTC] jon at hiveminds dot net
The use of a wildcard with the get_elements_by_tagname() method to obtain a collection of all DomElement nodes in a document appears to be broken in PHP4.3.4 for Windows. Rather than returning an array, it returns NULL. Upgrading broke numerous scripts depending on this behaviour, which reverted to normal as soon as I rolled back to 4.3.3.

The use of "*" as a wildcard in this fashion is per the W3C DOM spec, and performed as expected in PHP4.3.0-4.3.3 / win32.

Extensions enabled: cpdf, ctype, curl, domxml, gd2, iconv, ming, pdf, pgsql, xslt, yaz, zip

Versions of libxml, libxslt, and iconv used were those supplied in the distributions downloaded from

Server: IIS/5.0

The only other apps installed on this system are: MySQL 4.1-alpha, ActivePython-2.2.2-224, ActivePerl-, MSIE 5.0, MSXML 4.0

Reproduce code:
  //  Used 2 small XML files which are known 
  //  to be well-formed; domxml_open_file() succeeds
  //  in both cases

  if( !$map = domxml_open_file( realpath("xml/map.xml") ) )
  $alltags = $map->get_elements_by_tagname("*");
  echo count($alltags) . "<br>";
  echo (is_array($alltags) ? "ARRAY" : "NOT ARRAY") . "<br>";
  echo $alltags === NULL ? "NULL" : "NOT NULL";

Expected result:
Script output under PHP 4.3.3:



The XML files used contain 138 and 69 tags each (counting the document root), so these are correct. Both files were generated using DOMXML DomDocument->dump_file(real_path("path/to/file.xml"), FALSE, FALSE).

Actual result:
Same script and XML files under PHP 4.3.4:




Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2003-12-05 14:20 UTC]
This bug has been fixed in CVS.

In case this was a PHP problem, snapshots of the sources are packaged
every three hours; this change will be in the next snapshot. You can
grab the snapshot at
In case this was a documentation problem, the fix will show up soon at

In case this was a website problem, the change will show
up on the site and on the mirror sites in short time.
Thank you for the report, and for helping us make PHP better.

PHP Copyright © 2001-2022 The PHP Group
All rights reserved.
Last updated: Sat Aug 13 10:05:43 2022 UTC