142b858e7e66489dec395d0647b06d6b6fcf59e2
3 if (!defined("_ECRIRE_INC_VERSION")) return;
7 * Transforme un objet SimpleXML en tableau PHP
12 // http://www.php.net/manual/pt_BR/book.simplexml.php#108688
13 // xaviered at gmail dot com 17-May-2012 07:00
14 function inc_simplexml_to_array_dist($obj, $utiliser_namespace='false') {
18 // Cette fonction getDocNamespaces() est longue sur de gros xml. On permet donc
19 // de l'activer ou pas suivant le contenu supposé du XML
20 if (is_object($obj)) {
21 if ($utiliser_namespace)
22 $namespace = $obj->getDocNamespaces(true);
23 $namespace[NULL] = NULL;
25 $name = strtolower((string)$obj->getName());
26 $text = trim((string)$obj);
27 if (strlen($text) <= 0) {
32 $attributes = array();
34 // get info for all namespaces
35 foreach( $namespace as $ns=>$nsUrl ) {
37 $objAttributes = $obj->attributes($ns, true);
38 foreach( $objAttributes as $attributeName => $attributeValue ) {
39 $attribName = strtolower(trim((string)$attributeName));
40 $attribVal = trim((string)$attributeValue);
42 $attribName = $ns . ':' . $attribName;
44 $attributes[$attribName] = $attribVal;
48 $objChildren = $obj->children($ns, true);
49 foreach( $objChildren as $childName=>$child ) {
50 $childName = strtolower((string)$childName);
52 $childName = $ns.':'.$childName;
54 $children[$childName][] = inc_simplexml_to_array_dist($child);
61 'attributes'=>$attributes,