note 103025 deleted from book.simplexml by thiago

From: Date: Mon, 21 Mar 2011 13:55:26 +0000
Subject: note 103025 deleted from book.simplexml by thiago
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-178043@lists.php.net to get a copy of this message
Note Submitter: n dot dhuygelaere at oieau dot fr ---- This is a fix for the excelent contribution of svdmeer at xs4all dot nl. This function can handle multivaled xml node. function xml2array($xml) { $arXML=array(); $arXML['name']=trim($xml->getName()); $arXML['value']=trim((string)$xml); $t=array(); foreach($xml->attributes() as $name => $value){ $t[$name]=trim($value); } $arXML['attr']=$t; $t=array(); foreach($xml->children() as $name => $xmlchild) { $t[$name][]=xml2array($xmlchild); //FIX : For multivalued node } $arXML['children']=$t; return($arXML); }

« previous php.notes (#178043) next »