PHP 7.1.0 Released

DomDocument->get_elements_by_tagname

(PHP 4 >= 4.1.0)

DomDocument->get_elements_by_tagname Returns array with nodes with given tagname in document or empty array, if not found

Description

array DomDocument->get_elements_by_tagname ( string $name )

See also domdocument_add_root()

add a note add a note

User Contributed Notes 1 note

up
0
jon at hiveminds dot net
12 years ago
Warning to win32 users: It appears that use of the wildcard argument to this function (e.g.

<?php
  $alltags
= $domdoc->get_elements_by_tagname("*");
?>

) to return a collection of all DomElements in a document, which worked in php4.3.0-4.3.3, is broken in php4.3.4 for Windows. Upgrading broke numerous scripts depending on this behaviour, which returned to normal as soon as I rolled back to 4.3.3-win32.

I had intended to offer a workaround using child_nodes(), but found problems with this also. Therefore my suggested workarounds are either (a) don't upgrade to 4.3.4 if you're running this extension on Windows and are depending on the wildcard behaviour or (b) rewrite your code so as to use actual tagnames

The wildcard usage is per the W3C DOM spec, so hopefully this will be fixed and available again in 4.3.5.
To Top