note 89845 added to function.simplexml-element-children

From: Date: Wed, 25 Mar 2009 18:26:17 +0000
Subject: note 89845 added to function.simplexml-element-children
Groups: php.notes 
Request: Send a blank email to php-notes+get-152440@lists.php.net to get a copy of this message
I done a very nice function to run over the XML element recursivly with SimpleXML, and print it on the screen here it is: <?php $xml_han = new SimpleXMLElement( "data.xml", null, true ); print RecursiveXML( $xml_han ); function RecursiveXML( SimpleXMLElement $han, $preffix = "") { if( count( $han->children() ) < 1 ) { return $preffix . "&lt;" . $han->getName() . warpAttributes( $han->attributes() ) . "&gt;&nbsp;" . $han . "&nbsp;&lt;/" . $han->getName() . "&gt;<br />"; } $ret = $preffix . "&lt;" . $han->getName() . warpAttributes( $han->attributes() ) . "&gt;<br />"; foreach( $han->children() as $key => $child ) { $ret .= RecursiveXML($child , $preffix . "|--&nbsp;&nbsp;&nbsp;" ); } return $ret; } ?> enjoy :) ---- Server IP: 212.199.163.191 Probable Submitter: 79.177.113.210 ---- Manual Page -- http://www.php.net/manual/en/function.simplexml-element-children.php Edit -- https://master.php.net/note/edit/89845 Del: integrated -- https://master.php.net/note/delete/89845/integrated Del: useless -- https://master.php.net/note/delete/89845/useless Del: bad code -- https://master.php.net/note/delete/89845/bad+code Del: spam -- https://master.php.net/note/delete/89845/spam Del: non-english -- https://master.php.net/note/delete/89845/non-english Del: in docs -- https://master.php.net/note/delete/89845/in+docs Del: other reasons-- https://master.php.net/note/delete/89845 Reject -- https://master.php.net/note/reject/89845 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#152440) next »