note 108936 modified in simplexmlelement.addchild by danbrown

From: Date: Wed, 06 Jun 2012 17:49:21 +0000
Subject: note 108936 modified in simplexmlelement.addchild by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-188428@lists.php.net to get a copy of this message
I found myself doing something like:&#13;&#10;&#13;&#10;&#60;?php&#13;&#10;$cn = $contentNode-&#62;$name;&#13;&#10;?&#62;&#13;&#10;&#13;&#10;and keep getting an error message like: &#13;&#10;&#13;&#10;Warning: SimpleXMLElement::addChild(): Cannot add child. Parent is not a permanent member of the XML tree&#13;&#10;&#13;&#10;I found out that what I needed to do to make the node permanent was:&#13;&#10;&#13;&#10;&#60;?php&#13;&#10;$cn = $contentNode-&#62;$name = &#34;&#34;;&#13;&#10;$cn = $contentNode-&#62;$name;&#13;&#10;?&#62;&#13;&#10;&#13;&#10;hope will help someone else. --was-- I found myself doing something like: <? $cn = $contentNode->$name; ?> and keep getting an error message like: Warning: SimpleXMLElement::addChild(): Cannot add child. Parent is not a permanent member of the XML tree I found out that what I needed to do to make the node permanent was: <? $cn = $contentNode->$name = ""; $cn = $contentNode->$name; ?> hope will help someone else. http://php.net/manual/en/simplexmlelement.addchild.php

« previous php.notes (#188428) next »