|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2014-08-08 12:40 UTC] danielklein at airpost dot net
Description: ------------ DOMNodelist::item actually returns DOMElement, not DOMNode as stated in the documentation. Since DOMElement extends DOMNode, this is not a huge problem in that all the methods and properties will work as documented but the programmer is potentially missing out on a lot of useful features. Bug #42451 is also about this issue (but the reverse, asking for PHP to match the documentation). Perhaps a note in DOMNodelist::item explaining that as DOMElement extends DOMNode that it is actually correct? PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Oct 24 21:00:01 2025 UTC |
DOMNodeList::item() can return DOMElement but can also return other things that are DOMNodes, such as DOMText, DOMAttr. The example: <?php $doc = new DOMDocument; $doc->loadXML('<example a="Apple">Example</example>'); $xpath = new DOMXPath($doc); $nodelist = $xpath->query('/example/@*|/example/text()'); var_dump( get_class($nodelist), get_class($nodelist->item(0)), get_class($nodelist->item(1)) ); ?> Outputs: string(11) "DOMNodeList" string(7) "DOMAttr" string(7) "DOMText"