code: public static function convertXmlToPhpObj ($node)
      {
          $ret = array();
  
          if (is_object($node) && $node->hasChildNodes()) {
              foreach ($node->childNodes as $child) {
                  $name = self::decode($child->nodeName);
                  if ($child->nodeType == XML_TEXT_NODE) {
                      $ret = self::decode($child->nodeValue);
                  } else {
                      if ('array' === $name) {
                          return self::parseArray($child);
                      } else {
                          $ret[$name] = self::convertXmlToPhpObj($child);
                      }
                  }
              }
          }
          return !empty($ret) ? $ret : null;
      }
docs: convert SimpleXML to PhpObj