note 86807 deleted from function.simplexml-load-string by cmb
| From: | cmb@php.net | Date: | Sun, 15 Dec 2019 10:12:28 +0000 |
| Subject: | note 86807 deleted from function.simplexml-load-string by cmb | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-213529@lists.php.net to get a copy of this message | ||
Note Submitter: Mark Omohundro, ajamyajax.com
----
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()) {
echo "<br/>";
list_node($element);
}
}
}
?>