note 103025 added to book.simplexml
| From: | n dot dhuygelaere at oieau dot fr | Date: | Mon, 21 Mar 2011 11:39:44 +0000 |
| Subject: | note 103025 added to book.simplexml | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-178041@lists.php.net to get a copy of this message | ||
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);
}
----
Server IP: 69.147.83.197
Probable Submitter: 194.57.178.210
----
Manual Page -- http://www.php.net/manual/en/book.simplexml.php
Edit -- https://master.php.net/note/edit/103025
Del: integrated -- https://master.php.net/note/delete/103025/integrated
Del: useless -- https://master.php.net/note/delete/103025/useless
Del: bad code -- https://master.php.net/note/delete/103025/bad+code
Del: spam -- https://master.php.net/note/delete/103025/spam
Del: non-english -- https://master.php.net/note/delete/103025/non-english
Del: in docs -- https://master.php.net/note/delete/103025/in+docs
Del: other reasons-- https://master.php.net/note/delete/103025
Reject -- https://master.php.net/note/reject/103025
Search -- https://master.php.net/manage/user-notes.php