note 64837 added to function.simplexml-element-children
| From: | taylorbarstowatthatgooglemailthingy at osu1 dot php dot net | Date: | Fri, 21 Apr 2006 14:38:05 +0000 |
| Subject: | note 64837 added to function.simplexml-element-children | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-108932@lists.php.net to get a copy of this message | ||
Sometimes you actually want an array, not a pseudo array. This is especially true when you
aren't dealing with attributes (i.e., you just want the array of child nodes).
Do like this:
<?php
$children = $sxml->xpath('child::node()');
?>
The reason you might want this is to be able to use array functions like array_shift, array_pop,
etc. This is especially true when you are writing recursive functions. Simplexml works really well
in iterative programming, but if you try to implement recursion it gets ugly.
----
Server IP: 64.71.164.2
Probable Submitter: 68.165.149.2
----
X-Spam-Status: No, hits=3.1 required=5.0 tests=DATE_MISSING,FROM_NO_LOWER
autolearn=no version=2.64
----
Manual Page -- http://www.php.net/manual/en/function.simplexml-element-children.php
Edit -- http://master.php.net/note/edit/64837
Del: integrated -- http://master.php.net/note/delete/64837/integrated
Del: useless -- http://master.php.net/note/delete/64837/useless
Del: bad code -- http://master.php.net/note/delete/64837/bad+code
Del: spam -- http://master.php.net/note/delete/64837/spam
Del: non-english -- http://master.php.net/note/delete/64837/non-english
Del: in docs -- http://master.php.net/note/delete/64837/in+docs
Del: other reasons-- http://master.php.net/note/delete/64837
Reject -- http://master.php.net/note/reject/64837
Search -- http://master.php.net/manage/user-notes.php