note 105158 added to simplexmlelement.addchild

From: Date: Sun, 31 Jul 2011 14:32:29 +0000
Subject: note 105158 added to simplexmlelement.addchild
Groups: php.notes 
Request: Send a blank email to php-notes+get-182027@lists.php.net to get a copy of this message
If you're looking for a way to append children you may be interested in this: <php $x = new SimpleXMLElement('<root name="toplevel"></root>'); $f1 = new SimpleXMLElement('<child pos="1">alpha</child>'); $f2 = new SimpleXMLElement('<child pos="2">beta</child>'); $f3 = new SimpleXMLElement('<child pos="3">gamma</child>'); $x->{$f1->getName()} = $f1; $x->{$f2->getName()}[] = $f2; $x->{$f3->getName()}[] = $f3; echo 'count child=',$x->count(),"\n"; echo $x->asXML(); foreach ( $x->children() as $foo ) { var_dump($foo); } ?> ---- Server IP: 89.31.146.176 Probable Submitter: 82.67.73.53 ---- Manual Page -- http://www.php.net/manual/en/simplexmlelement.addchild.php Edit -- https://master.php.net/note/edit/105158 Del: integrated -- https://master.php.net/note/delete/105158/integrated Del: useless -- https://master.php.net/note/delete/105158/useless Del: bad code -- https://master.php.net/note/delete/105158/bad+code Del: spam -- https://master.php.net/note/delete/105158/spam Del: non-english -- https://master.php.net/note/delete/105158/non-english Del: in docs -- https://master.php.net/note/delete/105158/in+docs Del: other reasons-- https://master.php.net/note/delete/105158 Reject -- https://master.php.net/note/reject/105158 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#182027) next »