note 86807 modified in function.simplexml-load-string by danbrown

From: Date: Tue, 04 Nov 2008 22:14:03 +0000
Subject: note 86807 modified in function.simplexml-load-string by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-146135@lists.php.net to get a copy of this message
How about a recursive function to reduce the xml hard-coding in your apps? Here is my simple listing routine as an example: <?php function list_xml($str) { $root = simplexml_load_string($str); list_node($root); } function list_node($node) { foreach ($node as $element) { echo $element. "\n"; if ($element->children()) { list_node($element); echo "<br/>"; } } } ?> --was-- How about a recursive function to reduce the xml hard-coding in your apps? Here is my simple listing routine as an example: function list_xml($str) { $root = simplexml_load_string($str); list_node($root); } function list_node($node) { foreach ($node as $element) { echo $element. "\n"; if ($element->children()) { list_node($element); echo "<br/>"; } } } http://php.net/manual/en/function.simplexml-load-string.php

« previous php.notes (#146135) next »