Sometimes it seems that the DOMNodeList returned isn't live.
It IS live when using access like childNodes
$children=$doc->getElementsByTagName('body')->item(0)->childNodes;
echo $children->length; //7
$children->item(0)->parentNode->removeChild($children->item(0));
echo $children->length; //6! list is live!
But other times the list is NOT live...
$xpath=new DOMXPath($doc);
$nodes=$xpath->query("//p");
echo $nodes->length; // 7
$nodes->item(0)->parentNode->removeChild($nodes->item(0));
echo $nodes->length; // still 7? Not live.
XPath seems to be the major culprit. But why return a DOMNodeList if it isn't live? Why not just an array at that point?