Note that $length is calculated (php5.3.2).
Iterating over a large NodeList may be time expensive.
Prefer :
$nb = $nodelist->length;
for($pos=0; $pos<$nb; $pos++)
Than:
for($pos=0; $pos<$nodelist->length; $pos++)
I had a hard time figuring that out...