PHP如何构造DOMNodeList

时间:2017-01-18 22:47:59

标签: php domdocument

我意识到DOMNodeList是一种特殊类型的“实时”只读参考列表,但出于好奇,它是如何由其他类构建的?例如,DOMNode“getBy *”函数如何构造DOMNodeList?

//for example NOT with array of nodes
$doc=new DOMDocument();
$doc->loadHTML("<div></div><div></div>");
$list=new DOMNodeList([$doc->getElementsByTagName('div')->item(0)]);

echo $list->length;//doesn't work; empty; prints 0

0 个答案:

没有答案