If you want to add a new cd somewhere other than to the end of the childNodes array, you can use the insertBefore method. It works just like appendChild, except you also need to include a reference to the node before which the insertion should be made:
$cdLibrary =& $cdCollection->documentElement;
$cdLibrary->insertBefore($newNode, $cdLibrary->firstChild);
The insertBefore method returns a reference to the inserted node.
|