PHP DOMDocument: insertBefore, как заставить его работать?

Я хотел бы поместить новый элемент узла перед данным элементом. Я использую insertBefore для этого без успеха!

Вот код,

//$div is a new div node element,
//The code I'm trying, is the following:

$maindiv->item(0)->parentNode->insertBefore( $div, $maindiv->item(0) ); 

//Obs: This code asctually places the new node, before maindiv
//$maindiv object(DOMNodeList)[5], from getElementsByTagName( 'div' )
//echo $maindiv->item(0)->nodeName gives 'div'
//echo $maindiv->item(0)->nodeValue gives the correct data on that div 'some random text'
//this code actuall places the new $div element, before 
http://pastie.org/1070788

Любой вид справки ценится, Спасибо!

5
задан Nicola Peluchetti 21 May 2011 в 11:26
поделиться